|
Post by Candle on Jul 17, 2004 12:35:16 GMT -5
I used that one help on making that alien game and wondered if someone could help me a litle bit ? how would I set it so it runs for so many seconds and then the game ends ? And how would i get the alien to maybe drop something as it goes across the screen ? code .
dim score, lives, turretx, alienx, alieny dim bulletx, bullety, bulletOnScreen, i lives = 3 turretx = 19 alienx = 0 alieny = 12 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 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 ">O<" color (150, 150, 150) 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 bulletOnScreen = false alienx = 0 alieny = rnd () % 22 + 1 score = score + 100 Sleep (1000) endif DrawText () Sleep (75) wend Thanks for any help .. trying to learn .
|
|
|
Post by GuppyB on Jul 19, 2004 11:16:04 GMT -5
Here's some quick code that basically reverses what you were doing with the firing up. Also, deducts the lives and "Game Over"s when you get below 0. Hope this helps.
...G
dim score, lives, turretx, alienx, alieny dim bulletx, bullety, bulletOnScreen, i dim alienbulletx, alienbullety, abulletOnScreen
lives = 3 turretx = 19 alienx = 0 alieny = 12 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 if alienx = turretx and abulletOnScreen = false then alienbulletx = alienx + 1 alienbullety = alieny + 1 abulletOnScreen = true endif if abulletOnScreen then alienbullety = alienbullety + 1 if alienbullety > 24 then abulletOnScreen = false endif if bulletOnScreen then bullety = bullety - 1 if bullety < 1 then bulletOnScreen = false endif 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 ">O<" color (150, 150, 150) locate turretx, 23: print "<!>" if bulletOnScreen then color (255, 255, 50) locate bulletx, bullety: print "!" endif if abulletOnScreen then color (255, 255, 50) locate alienbulletx, alienbullety: 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 bulletOnScreen = false alienx = 0 alieny = rnd () % 22 + 1 score = score + 100 Sleep (1000) endif
if abulletOnScreen and alienbullety = 23 and alienbulletx >= turretx and alienbulletx <= turretx + 2 then color (255, 255, 100) for i = 1 to 10 locate turretx, 23: print "///" DrawText () Sleep (50) locate turretx, 23: print "\\\" DrawText () Sleep (50) next lives = lives - 1 if lives < 0 then locate 18,12: print "GAME OVER":DrawText():for i = 1 to 500: next: end endif endif
DrawText () Sleep (75) wend
|
|
|
Post by Candle on Jul 19, 2004 11:23:20 GMT -5
Alien shhots good but now the player has probleams firing . the bullet stops and then starts or stops 1/2 way up the screen ? or right after firing it stops and hit space a few times it will go again ?
|
|
|
Post by GuppyB on Jul 19, 2004 12:46:19 GMT -5
Yeah just noticed... got confused with the number of endifs... that's what I get for coding this "off the cuff" and not checking my work... try this:
...G
dim score, lives, turretx, alienx, alieny dim bulletx, bullety, bulletOnScreen, i dim alienbulletx, alienbullety, abulletOnScreen
lives = 3 turretx = 19 alienx = 0 alieny = 12 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
if alienx = turretx and abulletOnScreen = false then alienbulletx = alienx + 1 alienbullety = alieny + 1 abulletOnScreen = true endif
if abulletOnScreen then alienbullety = alienbullety + 1 if alienbullety > 24 then abulletOnScreen = false endif endif
if bulletOnScreen then bullety = bullety - 1 if bullety < 1 then bulletOnScreen = false endif endif if ScanKeyDown (VK_SPACE) then bulletOnScreen = true bullety = 22 bulletx = turretx + 1 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 ">O<" color (150, 150, 150) locate turretx, 23: print "<!>" if bulletOnScreen then color (255, 255, 50) locate bulletx, bullety: print "!" endif if abulletOnScreen then color (255, 255, 50) locate alienbulletx, alienbullety: 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 bulletOnScreen = false alienx = 0 alieny = rnd () % 22 + 1 score = score + 100 Sleep (1000) endif
if abulletOnScreen and alienbullety = 23 and alienbulletx >= turretx and alienbulletx <= turretx + 2 then color (255, 255, 100) for i = 1 to 10 locate turretx, 23: print "///" DrawText () Sleep (50) locate turretx, 23: print "\\\" DrawText () Sleep (50) next lives = lives - 1 if lives < 0 then locate 18,12: print "GAME OVER":DrawText():for i = 1 to 500: next: end endif endif
DrawText () Sleep (75) wend
|
|
|
Post by Candle on Jul 19, 2004 13:25:12 GMT -5
Hey GuppyB that works good now . now I'm trying to get some background sound working (it's not ) and I can play the laser.wav with the spacekey but then the game quits.
dim score, lives, turretx, alienx, alieny dim bulletx, bullety, bulletOnScreen, i dim alienbulletx, alienbullety, abulletOnScreen
lives = 3 turretx = 19 alienx = 0 alieny = 12 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
if alienx = turretx and abulletOnScreen = false then alienbulletx = alienx + 1 alienbullety = alieny + 1 abulletOnScreen = true endif
if abulletOnScreen then alienbullety = alienbullety + 1 if alienbullety > 24 then abulletOnScreen = false endif endif
if bulletOnScreen then bullety = bullety - 1 if bullety < 1 then bulletOnScreen = false endif endif if ScanKeyDown (VK_SPACE) then bulletOnScreen = true bullety = 22 bulletx = turretx + 1 dim sound sound = LoadSound ("Sounds\laser.wav") PlaySound (sound) endif
cls color (255, 255, 255) locate 0, 0: print "Score=" + score locate 30, 0: print "Lives=" + lives locate 13, 0: print "Space Blaster" color (255, 50, 50) locate alienx, alieny: print "<>O<>" color (150, 150, 150) locate turretx, 23: print "<!>" if bulletOnScreen then color (255, 255, 50) locate bulletx, bullety: print "!" endif if abulletOnScreen then color (255, 255, 50) locate alienbulletx, alienbullety: 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 bulletOnScreen = false alienx = 0 alieny = rnd () % 22 + 1 score = score + 100 Sleep (1000) endif
if abulletOnScreen and alienbullety = 23 and alienbulletx >= turretx and alienbulletx <= turretx + 2 then color (255, 255, 100) for i = 1 to 10 locate turretx, 23: print "///" DrawText () Sleep (50) locate turretx, 23: print "\\\" DrawText () Sleep (50) next lives = lives - 1 if lives < 0 then locate 18,12: print "GAME OVER":DrawText():for i = 1 to 500: next: end endif endif
DrawText () Sleep (75) wend dim sound, currentcount, lastcount, soundtime soundtime = 1000 ' set to length of sound clip in seconds * 1000 sound = LoadSound ("Sounds\richtervsdrac.wav") lastcount = TickCount() while true currentcount = TickCount () if (currentcount - lastcount) > soundtime then PlaySound (sound) lastcount = TickCount() endif wend
|
|