My apologies for hijacking this thread,maybe I should create a new one in the beginners area?
When I first bought blitz, I wrote a small test program to see if I would be able to learn to program enough to make a shmup. My test program has a scrolling background, enemies that move down the screen and shoot, player ship movement, etc... I tried to break everything down into seperate functions, and tried to keep the drawing and logic operations seperate. Here is what I have for (lame)bullet patterns:
Sorry for the excessive commenting, It's just so I don't forget what the heck I was trying to do. I'm not too good at reading code yet(even my own!)
Function createenemybullet() ; generate new enemy bullets
For weak1.enemyship = Each enemyship
If weak1\id = 1 ; select the first enemy ship
newenemybulletfast = Rand(1,100) ; temp variable to hold random number for intermittent bullet generation
If newenemybulletfast > 92 ; check temp variable to seldomly shoot bullets
basicbullet.enemybullet = New enemybullet ; create new enemy bullet
basicbullet\x = weak1\x ; set start x axis location @ enemy ship
basicbullet\y = weak1\y ; set start y axis location @ enemy ship
basicbullet\v = basicfastenemybulletspeed ; set speed
basicbullet\kind = "fastbullet" ; label as fast bullet
basicbullet\angle# = ATan2(player\x - basicbullet\x, player\y - basicbullet\y) ; aim bullet at players current location
End If ; end check for creating new bullet at random
End If ; end check for first enemy ship
If weak1\id = 2 ; select second enemy ship
newenemybulletslow = Rand(1,100) ; temp variable to hold random number for intermittent bullet generation
If newenemybulletslow > 75 ; check temp variable to seldomly shoot bullets
basicbullet.enemybullet = New enemybullet ; create new enemy bullet
basicbullet\x = weak1\x ; set start x axis location @ enemy ship
basicbullet\y = weak1\y ; set start y axis location @ enemy ship
basicbullet\v = basicslowenemybulletspeed ; set speed
basicbullet\kind = "slowbullet" ; label as slow bullet
basicbullet\angle# = Rand(0,359) ; aim bullet in random direction
End If ; end check for creating new bullet at random
End If ; end check for second enemy ship
Next ; loop back to next enemy ship
End Function
Function updateenemybullet() ; move or delete enemy bullets
For basicbullet.enemybullet = Each enemybullet ; loop through all enemy bullets
basicbullet\x = basicbullet\x + (Sin(basicbullet\angle#) * basicbullet\v) ; move enemy bullet on x axis for specific angle and modify by speed variable
basicbullet\y = basicbullet\y + (Cos(basicbullet\angle#) * basicbullet\v) ; move enemy bullet on y axis for specific angle and modify by speed variable
If basicbullet\y > plyfldht Or basicbullet\y < scrntop Or basicbullet\x > plyfldrt Or basicbullet\x < plyfldlft ; check for bullet offscreen
Delete basicbullet.enemybullet ; delete offscreen bullet
End If ; end check for offscreen bullet
Next ; jump back for next bullet
End Function
Function showenemybullet() ; draw the enemies bullets
For basicbullet.enemybullet = Each enemybullet ; loop through all enemy bullets
If basicbullet\kind = "slowbullet" ; check for slow enemy bullets
DrawImage(basicenemybullet2image,basicbullet\x,basicbullet\y) ; draw the slow enemy bullet
Else If basicbullet\kind = "fastbullet" ; check for fast enemy bullets
DrawImage(basicenemybullet1image,basicbullet\x,basicbullet\y) ; draw the fast enemy bullet
End If ; end check for kind of enemy bullets
Next ; loop back through for the next enemy bullet
End Function
Random spam fire, and aimed shots. Not too exciting...
Also, using random to set the timing of bullet generation is cheesy. What's a better way?
To do real patterns, I'm not sure what to do. Bulletml seems to make the process fairly easy, but maybe it's more trouble than it's worth to get it up and running with blitz?
Should I be trying to make my own editor(probably way beyond my ability)? I have particle candy(which I haven't even started to learn yet), should I setup my bullets as particles and use an existing editor(is that possible/practical)?
What would be the best way to hard code patterns? create a turret type assignable to an enemy that contains x number of barrels each facing x direction, that spawn bullets? What sort of fields should these types have? ID,speed,x,y,direction,time alive,anim stuff, anything else... Fancy algorithms?
Or should I setup different styles of patterns each in their own function? i.e. aimed shots vs. circle shots vs. star bursts vs. spiral vs. grouped shots vs. etc, etc, etc...