my code (above) wont work as of now...
I wrote it from a hotel and the hotel manager (ass) kicked me off and I couldnt finish -_-
I cant be arsed at the moment to rewrite the code but here are some snippets for you to work off of.
yes, it could make 100 enemies if you wanted
ex=0
for x=1 to 100
sprite x,ex,100,[imageforsprite]
inc ex,20
next x
sync
(this would run off the screen, but you get the idea.)
here's an example of what I did to store info on each of 5 enemies in my game...someone tell us if there's an easier way XD
dim enemyHealth(5)
dim enemyStrength(5)
dim enemyType$(5)
dim enemyX(5)
dim enemyY(5)
ex=0
for a=1 to 5
enemyHealth(a)=100
enemyStrength(a)=5
enemyType$(a)="Starship"
enemyX(a)=ex
enemyY(a)=ey
inc ex,20
next a
sync
(by the way, this assumes that your enemy sprite is 10x10px..."inc ex,20" spaces each 10 apart (10 for the next sprite + 10 for a space=20)
I havent gotten to my AI yet, but here's a code to check to see if your ship's sprite is under any of the five enemies. It then randomly (1 out of 4) shoots. (I'll leave out the shoot function...I'll just point it to a code section labeled "eshoot", where the variable "enemynum" tells the code which enemy shot a laser. assume sprite 6 is your ship's sprite, and it's 10x10px.)
this should *theoritcally* work.
rem (I really should learn to use sprite offset :P)
for y=1 to 5
eLeft=sprite x(y)
eRight=sprite x(y)+10
you=sprite x(6)+10
if you > eLeft and you < eRight
chance=rnd(4)
if chance=2
enemynum=y
gosub eshoot
endif
endif
next y
sync
hope that helped
EDIT:
I believe this is wrong.
enemy2x = 150
enemy2y = 30
enemy3x = 70
enemy3y = 30
enemy4x = -10
enemy4y = 30
enemy6x = 310
enemy6y = 30
enemy7x = 390
enemy7y = 30
enemy8x = 470
enemy8y = 30
enemy9x = 550
enemy9y = 30
This will work:
enemy(2,x) = 150
enemy(2,y) = 30
enemy(3,x) = 70
enemy(3,y) = 30
enemy(4,x) = -10
enemy(4,y) = 30
enemy(6,x) = 310
enemy(6,y) = 30
enemy(7,x) = 390
enemy(7,y) = 30
enemy(8,x) = 470
enemy(8,y) = 30
enemy(9,x) = 550
enemy(9,y) = 30
Try using for/next loops mroe often, its MUCH more efficient. inc [variable],[number to increase by] helps too. Look at the codes I posted above, and model off those.
Concept Software:
http://concept.dbspot.com
"Hey! HEY! Sir you can't park your car on the - oh...wait...it's not a van, it's just a fat kid!"