Skip to main content
gamedev.net
🔒 Locked

basic help

Started by mikewazhere May 1, 2008 at 5:22 PM 2 replies 850+ views
Original Post
mikewazhere
mikewazhere
I'm trying to code this spaceship game where your stuck in the middle and all you do is rotate to shoot enemies but i'm having trouble drawing the bullets. when I tried to draw the image with the line drawimage bullet,shot\x,shot\y it said "image does not exsist". but when I replaced it with drawimage bullet,300,400 it worked! the games only half finished but i'll post the code below. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;surounded a space ship game;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;by mike oosting;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AppTitle "surrounded" Graphics 800,600 AutoMidHandle True SetBuffer BackBuffer() ;images Global ship = LoadAnimImage("shipanim.bmp",50,50,0,4) Global enemydown = LoadImage("enemy.bmp") Global enemyleft = LoadImage("enemyleft.bmp") Global enemyup = LoadImage("enemyup.bmp") Global enemyright = LoadImage("enemyright.bmp") Global bullet = LoadImage("bullet.bmp") Global title = LoadImage("title.bmp") ;Global Global shipturn = 0 Global menu = 1 Global spacebar = 57 Global shotaim = shipturn ;types Type shot Field x,y End Type ;main loop While Not KeyDown(1) If menu = 2 Then DrawImage ship,400,300,shipturn If menu = 1 Then DrawImage title,400,300 shipspin() titlescreen() If KeyHit(spacebar) bulletstuff() EndIf Flip Cls Wend ;function titlescreen() Function titlescreen() If KeyHit(2) menu = 2 EndIf If menu = 1 Then Text 400,500,"press 1 for easy difficulty",True,True End Function ;function shipspin() Function shipspin() If KeyHit(205) shipturn = shipturn + 1 EndIf If KeyHit(203) shipturn = shipturn - 1 EndIf If shipturn = -1 Then shipturn = 3 If shipturn = 4 Then shipturn = 0 End Function ;function bulletstuff() Function bulletstuff() shots.shot = New shot shots\x = x shots\y = y For shot.shot = Each shot shots\x = shot\x - 1 shots\y = shot\y - 1 Next DrawImage bullet,shot\x,shot\y End Function
Nanook
Nanook
advice; Indent your code.
Captain P
Captain P
Tip: use the [source][/source] tags around your source-code to preserve formatting.

Also, telling us what language and libraries you're using would be helpfull.
mikewazhere
mikewazhere
its in basic and i'm using blitz basic v1.6(if that makes a difference) and when I copied and pasted the code it took out the indents here's the code the way you said to put it,

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;surounded a space ship game;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;by mike oosting;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AppTitle "surrounded"Graphics 800,600AutoMidHandle TrueSetBuffer BackBuffer();images   Global ship = LoadAnimImage("shipanim.bmp",50,50,0,4)   Global enemydown = LoadImage("enemy.bmp")   Global enemyleft = LoadImage("enemyleft.bmp")   Global enemyup = LoadImage("enemyup.bmp")   Global enemyright = LoadImage("enemyright.bmp")   Global bullet = LoadImage("bullet.bmp")   Global title = LoadImage("title.bmp");Global   Global shipturn = 0   Global menu = 1   Global spacebar = 57   Global shotaim = shipturn;typesType shot Field x,yEnd Type;main loopWhile Not KeyDown(1) If menu = 2 Then DrawImage ship,400,300,shipturn If menu = 1 Then DrawImage title,400,300shipspin()titlescreen()If KeyHit(spacebar)bulletstuff()EndIfFlipClsWend;function titlescreen()Function titlescreen() If KeyHit(2)  menu = 2 EndIf If menu = 1 Then Text 400,500,"press 1 for easy difficulty",True,TrueEnd Function;function shipspin()Function shipspin() If KeyHit(205)  shipturn = shipturn + 1 EndIf If KeyHit(203)  shipturn = shipturn - 1 EndIf If shipturn = -1 Then shipturn = 3 If shipturn = 4 Then shipturn = 0End Function;function bulletstuff()Function bulletstuff() shots.shot = New shot shots\x = x shots\y = y For shot.shot = Each shot  shots\x = shot\x - 1  shots\y = shot\y - 1 Next DrawImage bullet,shot\x,shot\yEnd Function

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.