Hi Delbar:
I have modified your code abit and it should work now. I have changed the imagenames to my needs and bring all bulletfunctions together to the bullet type to make it more OOP. Its not working well (short time to test) but it should show you how to make it.
I have modified your code abit and it should work now. I have changed the imagenames to my needs and bring all bulletfunctions together to the bullet type to make it more OOP. Its not working well (short time to test) but it should show you how to make it.
Global Player_1:Timage = LoadImage("gfx\raumschiff1.png") Global Player1bullet:TImage = LoadImage("gfx\rocket.bmp") Global player1X = 400 Global player1Y = 500 Global RunSpeed = 2 Global bulletList:TList Graphics 800,600,0,-1 While Not KeyDown(KEY_ESCAPE) Cls TileMap() Player1() Player1Input() If bulletlist <> Null Then bullet.Draw2() EndIf Flip FlushMem Wend Function TileMap() SetScale .2,.2 Local Grass = LoadImage("gfx\grass.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 If KeyHit(Key_Mouseleft) Then bb:Bullet = bullet.create() EndIf End Function AutoMidHandle True Type bullet Field x# Field y# Field origin_x# Field origin_y# Field life# Field scale_factor# Field alpha_factor# Function Create:Bullet() If Bulletlist = Null Then bulletlist = New Tlist Local mybullet:bullet = New bullet mybullet.life = 100 mybullet.alpha_factor=1 mybullet.x = Player1X mybullet.y = Player1Y myBullet.origin_x = Player1X myBullet.origin_y = Player1Y bulletList.addLast(mybullet) Return MyBullet End Function 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+(scale_factor*4),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 Function Draw2() SetBlend(AlphaBlend) For Local b:bullet = EachIn bulletList b.Draw() b.Update() Next SetAlpha 1 End Function End Type