How To

Some trouble with spawning mobs

0

Blockhead 2018-11-30 08:12

I want to make spawn randomly sprites but they spawn not different and in the same time, how fix it?


was8bit 2018-11-30 08:58

SPRITE Spritenumber,X,Y,Imagenumber

If you use the same Spritenumber, you are referencing the same SPRITE

So if you have 20 sprites, you could use numbers 1 thru 20 to get 20 different sprites

If you use the same Imagenumber (say they were all bullets) then they would all look alike... the image number references a character cell number.

To make the Sprite different colors, have different cell sizes, etc. is a little extra complicated... FIRST get SPRITE command to work correcty and I can help you on the extra things :)


was8bit 2018-11-30 09:03

Take a look at my Car Tag game... i use only 3 SPRITES in the game, and it is rather an easy read to check out :)


was8bit 2018-11-30 09:17

Another issue with randomly adding sprites is having code to control this ... check out my Sea Dogs game ... for the 40 potential bullets i use these variables to control each one bullet..

DIM BX(40),BY(40),BDX(40),BDY(40),BI(40)

BI() lets me know if a particular number is being used, kinda like is the bullet "ON" or "OFF".... they all start as OFF...

Then as a bullet is needed to be added I have to check all 40 numbers until I find one that isn't being used, BI(numberchecked)=0

Once i find a number not being used, I then use that number to set all the bullet variables for that number.... so if II represents the number found not being used, I set BI(II)=1, BX(II)=x position,,etc..

Also, I must have code that does NOT set anything if all the numbers are in use...

finally, to "animate" or show the sprites, I have another loop that will only use the SPRITE command to reposition the used moving bullets..

Also, once used, sprites tend to want to stay on the screen, so once a bullet is "used" and should be removed, I set BI(bulletnumber)=0, but I also use SPRITE bulletnumber,-10,-10, which effectively "hide" the bullet offf screen so you can't see it anymore... one could use other methods, but since I want to reuse the same image, i simply move the bullet off screen to hide it, that way it's image is always set to the same image, and all I have to do is reposition the bullet back to the screen to be seen again :)


Blockhead 2018-11-30 11:07

Bullets is easy but with aliens with different abilities?


was8bit 2018-11-30 11:29

Then add another variable ... for ailens, AK() meaning AlienKind... to identify the kind of alien being assigned to that index number...you could also create AC() meaning AlienCharactenumber if aliens with the same ability can have different looks... all of these variables use same index number to represent that one specific thing bring randomly created... just add enough variables to cover everything that will help your code identify and interact with that created thing :)


Blockhead 2018-11-30 11:30

Thanks


was8bit 2018-11-30 11:35

Now, lets consider a conplicated option, lets say aliens can have randomly assigned abilities ??? In that case you may try,,,

DIM AA(AlienIndexnumber,AbiliyIndexnumber)

Such that if there can be 40 aliens, and each can have 5 (say out of a possible 20) different abilities, then here is how that would work

II = an unused alien index number
So..

For AI=1 to 5
AA(II,AI)= INT(RND*20)
NEXT AI

to assign 5 different random abilities (out of 20 possibilities) to alien indexed by index number assigned to II (from a search for an unused index number)


Blockhead 2018-11-30 11:52

Ok, and for make it wait first spawn another?


was8bit 2018-11-30 12:01

You can make the wait conditional like for a set passage of time, or just random...

For time based, use
TSPAWN=TIMER+TIMER+(60*3) for 3 seconds
TSPAWN=TIMER+TIMER+(60*60*3) for 3 minutes

Then to activate...

IF TSPAWN-TIMER<0 THEN
(Spawn)
(Reset TSPAWN)
END IF


For random just..

IF INT(RND*1000)=0 THEN
(Spawn)
END IF

Test and adjust the 1000... 100 is much more frequent..


Blockhead 2018-11-30 12:08

And how save high score with poke? It say “illegal memory access”


was8bit 2018-11-30 12:09

I like adding in a LEVEL adjustor, making higher levels harder...

For example, for timer spawn.. if ILEVEL is your level number, starting at level 1...

TSPAWN=TIMER+(60*60/ILEVEL)
So, level 1 spawns every minute, level 2 every 30 seconds, level 3 every 20 seconds, level 4 every 15 seconds... level 6 every second...

Different math would produce different results

.. for random, something similar, use math with ILEVEL so they spawn more frequently at higher levels... ;)


Blockhead 2018-11-30 12:11

And for save high score with poke? It say “illegal memory access”


was8bit 2018-11-30 12:12 (Edited)

Currently we cannot save in game variables like scores, high scores, etc.. if you look at the memory chart in the help section PERSIST memory is not yet available..

If it works like in regular LowRes you would do this,,,

PERSIST HIGHSCORE

And then HIGHSCORE is saved from game to game... this works for regular LowRes, and will work for NX someday,,,, but not for now :(


was8bit 2018-11-30 12:13

You would only use it once just like you use DIM only once, up at the top of the code...


Blockhead 2018-11-30 12:17

Ok, thanks, I’m working on a Xmas special with 100% touch commands


was8bit 2018-11-30 12:20

Oooo... coool :)

... glad I could help :)


Blockhead 2018-11-30 16:04

:)


Blockhead 2018-12-05 08:41

Nothing work


was8bit 2018-12-05 11:08

Please attach your code to your next post :


Blockhead 2018-12-05 13:41

Later, now I’m making a similar game for try to debug


was8bit 2018-12-06 04:11

K


Blockhead 2018-12-06 07:32

This is the test game


Blockhead 2018-12-06 07:33

This is the test game


Blockhead 2018-12-06 07:33

This is the test game


Blockhead 2018-12-06 07:33 (Edited)

Test game, Warning! Flashing colours


was8bit 2018-12-06 09:22

Seems to be playing fine, yes? :)


Blockhead 2018-12-06 11:42

Yes


was8bit 2018-12-06 11:58

Cool :) looks good :)


Blockhead 2018-12-06 11:58

Thanks


Blockhead 2018-12-06 12:01 (Edited)

What you think about snoop dogg simulator? Is ironic, not offensive


was8bit 2018-12-06 14:38

I saw nothing offensive ...


Blockhead 2018-12-06 14:46

I know but I ask your opinion


was8bit 2018-12-06 20:41

Oh, well the gameplay is good :) the graphics are cool :)

I'm not familiar enough with the "subject" of the game, and so cannot provide any feedback on that... but the game is fun to play :)


Blockhead 2018-12-09 18:04

Now all work, except the aliens movements, the make 10 steps on x axis and stop to do nothing


Log in to reply.