After having had a look at the shootem up totorial hich wave made i thought about extending it a little bit.
My extended idea is that some enemys can shoot bigger more powerful bullets/rockets/projectiles. BUT i want the projectiles to desctructible by the player. Furthermore, i'd like to know the owner of a projectile.
Now i cant figure out a way to know the owner of a projectile. I have created a clsBullet which extends the TGameObject.
Its baffling me, and the collision detection.. how can i know who shot a bullet??
check out my code, which extends Wave's code.
All of the above is to be implemented in a 99.999% portable OOP-way.
My extended idea is that some enemys can shoot bigger more powerful bullets/rockets/projectiles. BUT i want the projectiles to desctructible by the player. Furthermore, i'd like to know the owner of a projectile.
Now i cant figure out a way to know the owner of a projectile. I have created a clsBullet which extends the TGameObject.
Its baffling me, and the collision detection.. how can i know who shot a bullet??
check out my code, which extends Wave's code.
'#Region clsBullet Type clsBullet Extends clsGameObject Field MovementSpeedX:Int; Field MovementSpeedY:Int; Field Layer:Int; Field Image:TImage; Field DeltaDelay:Int; Field IncrementsPosX:Int; '// beweeg die kogel met nnn-aantal pixels per frame. Field IncrementsPosY:Int; Field DefaulStartPosX:Int; '// bij instantieer nieuwe object; dit is startX positie. Field DefaulStartPosY:Int; '// bij instantieer nieuwe object; dit is startY positie. Field IsDestructable:Int '//Sometimes, a enemy shoots a projectile which could be destroyable by the player' projectile, default is invincible enemy projectiles. Function Create:clsBullet() Local objBullet1:clsBullet = New clsBullet; objBullet1.MovementSpeedX = 3; objBullet1.MovementSpeedY = 3; objBullet1.ObjectID = MilliSecs(); objBullet1.Layer = 0; objBullet1.DeltaDelay = 40; '// 40 millisecs objBullet1.IncrementsPosX = 4; objBullet1.IncrementsPosY = 4; objBullet1.DefaulStartPosX = 0; objBullet1.DefaulStartPosY = 0; objBullet1.IsDestructable = False; Return objBullet1; End Function Method Update:clsBullet() If(MilliSecs() > MilliSecs() + Self.DeltaDelay) If(Image = Null) DrawOval(Self.Xpos1, Self.Ypos1, 3, 9); EndIf EndIf End Method Method MoveBullet:clsBullet() Try Self.Xpos1:+ Self.IncrementsPosX; Self.Ypos1:+ Self.IncrementsPosY; Catch ex1:String Throw ex1; EndTry End Method Function CollidedWith:clsBullet() End Function End Type '#EndRegion
All of the above is to be implemented in a 99.999% portable OOP-way.