Test trying to post my code. Am trying to get an bullet image(bmp) to shoot from my sprites gun and travel across the screen either to a certain distance or off the screen or stop when it hits something( collision to come later)
SetMaskColor 244,21,241' Magenta Global Player_1:Timage = LoadImage("gfx\player1.bmp") Global Player1bullet:TImage = LoadImage("gfx\bullet.bmp") Global player1X = 400 Global player1Y = 500 Global RunSpeed = 2 While Not KeyDown(KEY_ESCAPE) Cls TileMap() Player1() Player1Input() Bullets() Flip FlushMem Wend Function TileMap() SetScale .2,.2 Local Grass = LoadImage("gfx\Grass2.bmp") TileImage Grass End Function Function Player1() MidHandleImage Player_1 SetScale .4,.4 DrawImage Player_1,player1X,player1Y End Function Function Player1Input() If KeyDown(Key_Left) player1X:- RunSpeed 'Decrease X <-- Go left If KeyDown(Key_Right) player1X:+ RunSpeed 'Increase X --> Go Right If KeyDown(Key_Down) player1Y:+ RunSpeed 'Increase Y Go Down \/ If KeyDown(Key_Up) player1Y:- RunSpeed 'Decrease Y Go Up /\ If KeyHit(Key_Space) player1X=400;player1Y=500 'Set poss End Function AutoMidHandle True Global bulletList:TList Type bullet Field x# Field y# Field origin_x# Field origin_y# Field life# Field scale_factor# Field alpha_factor# Method draw() SetMaskColor 244,21,241 ' Magenta SetScale 1,1 DrawImage Player1bullet,x,y+(scale_factor*5),0 SetAlpha alpha_factor DrawImage Player1bullet,origin_x,origin_y,0 End Method Method update() y:-1 life:-1 scale_factor:-3 alpha_factor:-0.03 If(alpha_factor+10 <0) ListRemove bulletList,Self End Method End Type Function UpdateBullets() For Local b:bullet = EachIn bulletList b.Draw() b.Update() Next End Function Function Bullets() bulletList = CreateList() If KeyHit(KEY_MOUSELEFT) Local mybullet:bullet = New bullet mybullet.life = 100 mybullet.alpha_factor=1 mybullet.x = Player1X mybullet.y = Player1Y myBullet.origin_x = mybullet.x myBullet.origin_y = mybullet.y bulletList.addLast(mybullet) End If UpdateBullets() End Function End