|
Post by Ranger1800 on Jun 19, 2004 14:27:48 GMT -5
I just need to know how i would go about placing more enemies on the screen for like Space Invaders and how would i make shoot back at me?
|
|
|
Post by Ranger1800 on Jun 19, 2004 14:50:46 GMT -5
i'm getting a wend without while error on this game whats wrong i have the while statement:
dim score, lives, turretx, alienx, alieny, alienx2, alieny2 dim bulletx, bullety, bulletOnScreen, i lives = 3 turretx = 19 alienx = 0 alieny = 12 alienx2 = 5 alieny2 = 15 bulletOnScreen = false
TextMode (Text_Buffered) while true if ScanKeyDown (Vk_Left) and turretx > 0 then turretx = turretx - 1 endif if ScanKeyDown (Vk_Right) and turretx < 37 then turretx = turretx + 1 endif alienx = alienx + 1 if alienx > 37 then alienx = 0 alieny = rnd () % 22 + 1 endif alienx2 = alienx2 + 1 if alienx2 > 37 then alienx2 = 0 alieny2 = rnd () % 22 + 1 endif if bulletOnScreen then bullety = bullety - 1 if bullety < 1 then bulletOnScreen = false endif else if ScanKeyDown (Vk_Space) then bulletOnScreen = true bullety = 22 bulletx = turretx + 1 endif endif
cls color (255, 255, 255) locate 0, 0: print "Score=" + score locate 30, 0: print "Lives=" + lives color (255, 50, 50) locate alienx, alieny: print ">0<" color (150, 150, 150) locate alienx2, alieny2: print ">M<" color (151, 151, 151) locate turretx, 23: print "<!>" if bulletOnScreen then color (255, 255, 50) locate bulletx, bullety: print "!" endif if bulletOnScreen and bullety = alieny and bulletx >= alienx and bulletx <= alienx + 2 then color (255, 255, 100) for i = 1 to 10 locate alienx, alieny: print "///" DrawText () sleep (50) locate alienx, alieny: print "\\\" DrawText () sleep (50) next if bulletOnScreen and bullety = alieny2 and bulletx >= alienx2 and bulletx <= alienx2 + 2 then color (255, 255, 100) for i = 1 to 10 locate alienx2, alieny2: print "///" DrawText () sleep (50) locate alienx2, alieny2: print "\\\" DrawText () sleep (50) next bulletOnScreen = false alienx = 0 alieny = rnd () % 22 + 1 score = score + 100 sleep (1000) endif
DrawText () sleep (75) wend
|
|
|
Post by AHBanen on Jun 19, 2004 15:27:49 GMT -5
Hi, You forgot an EndIf. I put one in where your coding style suggested you forgot one and got horizontal flying enemies I could should at (Shows promising ): dim score, lives, turretx, alienx, alieny, alienx2, alieny2 dim bulletx, bullety, bulletOnScreen, i lives = 3 turretx = 19 alienx = 0 alieny = 12 alienx2 = 5 alieny2 = 15 bulletOnScreen = false TextMode (Text_Buffered) while true if ScanKeyDown (Vk_Left) and turretx > 0 then turretx = turretx - 1 endif if ScanKeyDown (Vk_Right) and turretx < 37 then turretx = turretx + 1 endif alienx = alienx + 1 if alienx > 37 then alienx = 0 alieny = rnd () % 22 + 1 endif alienx2 = alienx2 + 1 if alienx2 > 37 then alienx2 = 0 alieny2 = rnd () % 22 + 1 endif if bulletOnScreen then bullety = bullety - 1 if bullety < 1 then bulletOnScreen = false endif else if ScanKeyDown (Vk_Space) then bulletOnScreen = true bullety = 22 bulletx = turretx + 1 endif endif cls color (255, 255, 255) locate 0, 0: print "Score=" + score locate 30, 0: print "Lives=" + lives color (255, 50, 50) locate alienx, alieny: print ">0<" color (150, 150, 150) locate alienx2, alieny2: print ">M<" color (151, 151, 151) locate turretx, 23: print "<!>" if bulletOnScreen then color (255, 255, 50) locate bulletx, bullety: print "!" endif if bulletOnScreen and bullety = alieny and bulletx >= alienx and bulletx <= alienx + 2 then color (255, 255, 100) for i = 1 to 10 locate alienx, alieny: print "///" DrawText () sleep (50) locate alienx, alieny: print "\\\" DrawText () sleep (50) next endif 'I think you forgot this endif if bulletOnScreen and bullety = alieny2 and bulletx >= alienx2 and bulletx <= alienx2 + 2 then color (255, 255, 100) for i = 1 to 10 locate alienx2, alieny2: print "///" DrawText () sleep (50) locate alienx2, alieny2: print "\\\" DrawText () sleep (50) next bulletOnScreen = false alienx = 0 alieny = rnd () % 22 + 1 score = score + 100 sleep (1000) endif DrawText () sleep (75) wend Have fun programming, in Basic4GL! André
|
|
|
Post by Ranger1800 on Jun 19, 2004 15:42:52 GMT -5
lol now i have another small problem, when i hit the >o< enemy ship the explosion animation goes off but after the program sleeps the score doesn't go up and the bullet goes right through the enemy after the program sleeps what gives?
|
|
|
Post by Tom Mulgrew on Jun 19, 2004 18:55:41 GMT -5
The best way to get multiple enemies on the screen is to use an array. I'm planning to put this in at the start of the next tutorial.
|
|
|
Post by Ranger1800 on Jun 19, 2004 19:19:17 GMT -5
When do you plan to have the rest of the tutorial up Tom?
|
|
|
Post by AHBanen on Jun 21, 2004 8:08:44 GMT -5
I really don't want to be drawn into this Please, please try to find the error yourself first; read the code line by line and wonder if it's correct. But for this time another correction: dim score, lives, turretx, alienx, alieny, alienx2, alieny2 dim bulletx, bullety, bulletOnScreen, i lives = 3 turretx = 19 alienx = 0 alieny = 12 alienx2 = 5 alieny2 = 15 bulletOnScreen = false TextMode (Text_Buffered) while true if ScanKeyDown (Vk_Left) and turretx > 0 then turretx = turretx - 1 endif if ScanKeyDown (Vk_Right) and turretx < 37 then turretx = turretx + 1 endif alienx = alienx + 1 if alienx > 37 then alienx = 0 alieny = rnd () % 22 + 1 endif alienx2 = alienx2 + 1 if alienx2 > 37 then alienx2 = 0 alieny2 = rnd () % 22 + 1 endif if bulletOnScreen then bullety = bullety - 1 if bullety < 1 then bulletOnScreen = false endif else if ScanKeyDown (Vk_Space) then bulletOnScreen = true bullety = 22 bulletx = turretx + 1 endif endif cls color (255, 255, 255) locate 0, 0: print "Score=" + score locate 30, 0: print "Lives=" + lives color (255, 50, 50) locate alienx, alieny: print ">0<" color (150, 150, 150) locate alienx2, alieny2: print ">M<" color (151, 151, 151) locate turretx, 23: print "<!>" if bulletOnScreen then color (255, 255, 50) locate bulletx, bullety: print "!" endif 'sleep (1000) DrawText () 'added if bulletOnScreen and bullety = alieny and bulletx >= alienx and bulletx <= alienx + 2 then color (255, 255, 100) for i = 1 to 10 locate alienx, alieny: print "///" DrawText () sleep (50) locate alienx, alieny: print "\\\" DrawText () sleep (50) next bulletOnScreen = false alienx = 0 alieny = rnd () % 22 + 1 score = score + 100 sleep (1000) endif 'I think you forgot this endif if bulletOnScreen and bullety = alieny2 and bulletx >= alienx2 and bulletx <= alienx2 + 2 then color (255, 255, 100) for i = 1 to 10 locate alienx2, alieny2: print "///" DrawText () sleep (50) locate alienx2, alieny2: print "\\\" DrawText () sleep (50) next bulletOnScreen = false alienx2 = 0 alieny2 = rnd () % 22 + 1 score = score + 100 endif DrawText () sleep (75) wend Have fun programming! André
|
|
|
Post by Supermonkey on Jun 23, 2004 10:38:34 GMT -5
Going to the multiple enemy thing you could do something like this:
dim Dat,DatPos(4)(4) dim x,y
for x = 0 to 4 for y = 0 to 4 'read in the values in the data block one by one into dat read Dat 'asign the value in Dat to our array DatPos(x)(y) = Dat 'if the value in the array = 0 print a @ if DatPos(x)(y) = 0 then locate x,y print "@" endif 'if the value = 1 print # if DatPos(x)(y) = 1 then locate x,y Print "#" endif next next
'the data statements holding the values and positions of the charecters data 0,0,0,0,0 data 0,0,1,0,0 data 0,1,1,1,0 data 0,0,1,0,0 data 0,0,0,0,0
The explanation is totally poor sorry, but I'm in a rush. Just finished my exams gotta go party ;D
cheers Jonny
|
|