i have a slight problem and its late and i cant get my brain around it at them moment. I find it helps if i post what im trying to do and sometimes i end up answering my own question.
anyway, im trying to work out how to display more than one enemy at the same time. The actually enemy code isnt a problem but it the frames trigger. if i have say three enemies but all have different frame lengths how do monitor these lengths and tell the loop not to display an enemy if its already showing. heres my code at the moment:
Rem ********** MORLOCS SHOOTING ALLEY **********
set display mode 1024,768,32
hide mouse
sync rate 30
rem load images
load Image "scope2.png",1
Load Image "image1.png" , 10
Load Image "image2.png" , 11
Load Image "image3.png" , 12
Load Image "image4.png" , 13
Load Image "image5.png" , 14
Load Image "image6.png" , 15
Load Image "image7.png" , 16
Load Image "0gun.png" , 20
Load Image "1gun.png" , 21
Load Image "2gun.png" , 22
Load Image "3gun.png" , 23
Load Image "4gun.png" , 24
Load Image "5gun.png" , 25
Load Image "6gun.png" , 26
Load Image "7gun.png" , 27
Load Image "reload.bmp", 3
load image "dgrave.bmp",50
load image "fog.bmp", 51
load image "title1.bmp", 52
load image "healthbar.pcx", 30
Load Image "bat1.png" , 31
Load Image "bat2.png" , 32
Load Image "bat3.png" , 33
Load Image "bat4.png" , 34
Load Image "bat5.png" , 35
Load Image "bat6.png" , 36
Load Image "bat7.png" , 37
Load Image "bat8.png" , 38
Load Image "bat9.png" , 39
Load Image "bat10.png" , 40
rem sets music
load sound "reload.wav", 10
load sound "gun.wav", 11
load sound "emptychamber.wav", 12
load sound "m.wav",1
load sound "CREAK.wav", 13
load sound "vo_reload.wav", 14
set sound volume 1,50
backdrop off
autocam off
sync on
rem set variables
frame = 0
nme2frame = 0
speed = 1
bullets = 7
bulletrate = 6
delay = 1
batspeed = 0
sprite 52,0,0,52
rem play sound 13
wait 1000
wait key
sprite 52,1024,768,52
sprite 30,970,320,30
rem sets background
MAKE OBJECT PLAIN 4,1024,768
TEXTURE OBJECT 4,50
POSITION OBJECT 4,0,0,641
Set Camera to Object Orientation 4
rem end
rem sets fog plain
MAKE OBJECT PLAIN 5,1020,50
TEXTURE OBJECT 5,51
POSITION OBJECT 5,0,100,640
ghost object on 5
rem end
loop sound 1
rem start main loop
do
sync
Enemy = 1 rem this variable decides what enemy to display
sprite 20,20,610,(20+bullets)
set cursor 10,10: Print "xcoord ";mx;" "; "ycoord ";my
inc speed
if speed = 3 then inc nme1frame : inc nme2frame : speed = 1 : SCROLL OBJECT TEXTURE 5,0.001,0
gosub enemy1
gosub enemy2
gosub mouse
loop
end
rem main loop end
rem **** mouse bullet and reload code ****
mouse:
mx=mousex()
my=mousey()
sprite 1,(mx-spritewidth),(my-spriteheight),1
spritewidth=(sprite width(1)/2)
spriteheight=(sprite height(1)/2)
if MOUSECLICK()=1
if bulletrate=6
if bullets > 0
play sound 11
dec bullets
bulletrate=1
else
sprite 3,340,300,3
play sound 14
endif
endif
endif
if MOUSECLICK()=2
if delay => 6
bullets=7 : sprite 3,-450,300,3 : play sound 10 : delay = 1
endif
endif
if bulletrate < 6 then inc bulletrate
inc delay
return
rem **** code end ***************************
rem ************** enemy 1 code *************
enemy1:
If Enemy = 1 then nme1Numberofframes = 7 : nme1x = 700 : nme1y = 500 : nme1Framestart = 10
if nme1frame = nme1Numberofframes + 1 then nme1frame = 0
sprite 10,nme1x,nme1y,(nme1framestart + nme1frame)
return
rem **** code end ****
rem *********** enemy 2 : bat code ************
enemy2:
If Enemy = 2 then nme2Numberofframes = 9 : nme2x = 1000 : nme2y = 100 : nme2Framestart = 31
if nme2frame => nme2Numberofframes + 1 then nme2frame = 0
sprite 31,(nme2x-batspeed),nme2y-rnd(10),(nme2framestart + nme2frame)
batspeed = batspeed +5
if (nme2x-batspeed) <= -100 then nme2x = 1000 : batspeed = 0
return
rem *********** code end ***************
I like the enemy gosubs and enmy code as it works well. Im not sure if its worth making them functions that way i could in theory have just one bi of code to do multiple enemies. The two i have at the moment are a stationary one and a flying one.
any suggestions welcome
Morloc