Doodle strike

1

Tinycloud778 2019-05-08 18:41 (Edited)

I’m working on a two player game shooter

2019-05-09 18:54
2019-05-08 19:47
2019-05-08 19:32
2019-05-08 18:56
2019-05-08 18:41

Tinycloud778 2019-05-08 19:33

I’m trying to find a way to make enemies spawn with DIM and please help me I can’t find how to do it

was8bit 2019-05-09 07:03 (Edited)

Use a DIM STAT() to control the status of an enemy

STAT(I)=0 means enemy doesn’t exist, =1 means it does exist... if you have different enemies states, use different numbers for each state.. :)

Tinycloud778 2019-05-09 18:55

Umm what happened here???

Tinycloud778 2019-05-09 18:55

Sorry, I’m not good at DIM or arrays

dredds 2019-05-09 19:17 (Edited)

There are 64 sprites numbered 0 to 63. The following statement creates an array to hold the status of each sprite and initialises them all to zero.

``DIM GLOBAL STAT(63)``

To record that a sprite is in use, set its status to 1. Eg:

``````SPRITE 0, 100, 100, 1
STAT(0) = 1
SPRITE 1, 40, 40, 2
STAT(1) = 1``````

Now, to animate the sprites, use a for loop to iterate over the elements of the array and change the properties of any sprite for which the STAT array has an element of value 1:

``````DO
FOR I = 0 TO 63
IF STAT(I) = 1 THEN
SPRITE I, SPRITE.X(I)+1, SPRITE.Y(I)+1,
END IF
NEXT I
WAIT VBL
LOOP``````

That’s not much fun! All the sprites just move in a straight line. For a game, each sprite should behave differently. To achieve that, we store different values in STAT: the value for a sprite represents the behaviour we want the sprite to have. I like to implement the behaviour of each sprite in its own subroutine. So our loop will now look like:

``````DO
FOR I = 0 TO 63
IF STAT(I) = 1 THEN
CALL ANIMATE_PLAYER(I)
ELSE IF STAT(I) = 2 THEN
CALL ANIMATE_ENEMY(I)
ELSE IF STAT(I) = 3 THEN
CALL ANIMATE_BULLET(I)
ELSE IF STAT(I) = 4 THEN
CALL ANIMATE_EXPLOSION(I)
END IF
NEXT I

WAIT VBL
LOOP

SUB ANIMATE_PLAYER(I)
‘ whatever you want the player to do...
END SUB

‘ and the other subroutines ...``````

And that’s the basis of a game loop with different types of sprite.

Tinycloud778 2019-05-09 20:58

Ok... I kinda understand
(Sorry I’m bad at understanding well)

Tinycloud778 2019-05-09 20:59

But thanks for the code

Tinycloud778 2019-05-09 21:00

I’ll try to implement it into my code

was8bit 2019-05-09 23:56

... try looking at this :)

https://lowresnx.inutilis.com/topic.php?id=437