|
Post by Nonsense in BASIC on May 8, 2012 10:38:19 GMT
Can someone just clear up how this works please? I'm using it to determine which way a sprite is moving and then in turn, which way it's shooting. Maybe I'm going about this the wrong way but I'm doing something like this (in it's simplist form): IF DIRECTION 1 SPRITERIGHT END IF IF DIRECTION 0 SPRITELEFT END IF I'm putting this in the 'bullet' sprite script after 'SPAWN' - ing it in the main sprite script (0) - is this right? Any help would be appreciated Cheers.
|
|
|
Post by BiNMaN on May 8, 2012 18:54:05 GMT
Direction, pretty much the same as param and paramb are variables unique to the spawned sprite and can be used similar to the global variables
they can also be sein in the sprite initialisation
ie
if type 1 let direction = 1 endif
This could be used to send a sprite in different vector as parama, paramb and direction are set to 0 when a sprite spawns, but it all depends what you do with it!
For player sprite movement you don't really need to use direction as your movements are controlled by your key presses. Direction is useful in enemy ai as they have no real input in trheir movement except by bouncing of a block or finding a ladder etc.
Where it could come in usefull is if you have an 8 way movement (just been working on one) again it's just used as a variable
ie
if key 0 add 1 to direction if direction = 8 let drection = 0 endif endif
if key 1 subtract 1 from direction if direction = 255 let direction = 7 endif endif
let a = direction
if direction = 0 if cangoup spriteup endif endif
if direction = 1 if cangoright spriteright endif if cangoup spriteup endif endif
etc untill you've gone all the way around, by setting a to equal direction you can then pop this into another sprite type (eg 1) that is your bullet
so in the sprite initialistaion put
if type 1 let direction = a endif
then in sprite type 1 put
if direction = 0 if cangoup spriteup endif endif
if direction = 1 if cangoright spriteright endif if cangoup spriteup endif endif
etc so when the sprite is spawned it will take on the direction the player is facing
just to recap drection, parama and paramb are variables that are unique to the sprite, can store a number from 0-255, and can be used to make conditions only for that sprite, whereas global variables a-p can be used and affected in any part of the game
|
|
|
Post by Nonsense in BASIC on May 9, 2012 12:44:04 GMT
Thanks BiNMaN.
That's explained it but now I realise I'm barking up the wrong tree. I can't get the control sprite to fire in the direction it's facing.
I've got to the point where it will fire in different directions but if you fire right then turn left the bullets turn left with the control sprite as well. I know why this is (global variables) but I'm struggling to work out how to say 'If sprite 0 is facing left, then send sprite 7 left' it should be simple but i'm pulling my hair out!!!
|
|
|
Post by BiNMaN on May 9, 2012 18:05:06 GMT
keep a global variable just for that so going back to what I wrote when you facing a direction set the global then reverse the process into the bullet sprite so for this example sprite type 1 is the bullet in the player (sprite type 0) use DIRECTION to track the direction the sprite is going, let's say it your movement is left and right so:- IF KEY 0 IF CANGOLEFT LET DIRECTION = 0 (you could just use a global variable for this but it's useful just to use DIRECTION as it could be more aplicable in other types of movement) SPRITELEFT ENDIF IF KEY 1 IF CANGORIGHT LET DIRECTION = 1 SPRITERIGHT ENDIF LET A = DIRECTION now in the Initialise Sprite part of the events menu put IF TYPE 1 LET DIRECTION = A ENDIF now in sprite type 1 you'll need to put IF DIRECTION = 0 IF CANGOLEFT SPRITELEFT SPRITELEFT (spriteleft twice so the bullet moves away from the player even when the player is moviung otherwise it'll stay just by him) ENDIF ENDIF IF DIRECTION = 1 IF CANGORIGHT SPRITERIGHT SPRITERIGHT ENDIF ENDIF because DIRECTION, PARAMA and PARAMB are unique to each individulal sprite on the screen (and no matter how many of the same type) anything stored as a variable using these three cannot be affected by other sprites or conditions unless you want it to be affected here's an example of the rotational thing I described in an earlier post myweb.tiscali.co.uk/binman/example.szx9 left 0 right 2 thrust and Z fire bit weird I know but what I'm doing now has an autofire
|
|
|
Post by Nonsense in BASIC on May 10, 2012 13:05:28 GMT
Thanks again BiNMaN!
The double 'SPRITERIGHT' was also causing me a headache!
(Nice rotational ship by the way)
|
|
|
Post by Jonathan Cauldwell on May 10, 2012 17:36:33 GMT
If it makes it easier, this
SPRITERIGHT SPRITERIGHT can be replaced with this
ADD 4 TO Y at the cost of an extra byte or so.
|
|
|
Post by Nonsense in BASIC on May 14, 2012 22:48:29 GMT
If it makes it easier, this SPRITERIGHT SPRITERIGHT can be replaced with this ADD 4 TO Y at the cost of an extra byte or so. Ahhh! of course. Thanks Jonathan
|
|
|
Post by Rickeytab on Oct 8, 2020 15:58:26 GMT
Наша компания занимается расскруткой продвижение сайта буржунет совершенно не дорого. В случае, если у вас существует свой бизнес, тогда рано или поздно вы лично осознаете, что без оптимизация и продвижение сайтов сшау вас нет возможности работать дальше. Сейчас фирма, которая подумывают о собственном будущем развитии, должна иметь веб-сайт для seo продвижение сайтов google. продвижение англоязычного сайта в google- способ, используя который возможно приобретать новых покупателей, и дополнительно получить проценты, с тем чтобы рассказать об наличии вашей собственной производственной компании, её продуктах, функциях. Специализированная международная фирма сделать для вашей фирмы инструмент, с помощью которого вы сможете залучать правильных партнеров, получать прибыль и расти.Продающийся сайт- лицо фирмы, в связи с этим имеет значение, кому вы доверяете создание своего веб страницы. Мы - команда профи, которые имеют обширный практический опыт конструирования электронную коммерцию с нуля, направления, разработанного типа. Сотрудники нашей фирмы неизменно действуем по результатом. Международная компания сумеет предоставить всем нашим заказчикам профессиональное сопровождение по доступной антикризисной расценке.Вы можете сделать заказ онлайн-визитку, рекламный сайт. Не сомневайтесь, что ваш портал будет разработан высококлассно, с разными самыми новыми технологиями. <a href=https://apistudio.ru>продвижение сайта в топ сша</a>
|
|