Games Arrow throwing

hookshy

Well-Known Member
Licensed User
Longtime User
The code is uggly but here is how the result looks like:

http://danken.ro/pub/arrow.mp4


'calculating the angle for arrow direction (canvas pivot)
B4X:
'xf=cursor position
'yf=cursor position
  Dim Angle As Double
  Angle = ATan2D(yf - Player.y, xf - Player.x)
  destangle = Angle

'Calculting the desired target of the object with no gravity
B4X:
'this returns the points from a circle distance 300 dip from the player
'destx  - as desired destionation on x coordonate

 destx=Player.X+300dip*CosD(Angle)
 desty=Player.Y+300dip*SinD(Angle)



'the shooting power
B4X:
streng = Sqrt(Power(Abs(Player.x - xf),2) + Power(Abs(Player.Y - yf),2))/(Activity.Height-Player.Y)

'create new arrow and shot
B4X:
                Dim LaserShot As typLaser
                LaserShot.X = Player.X
                LaserShot.Y = Player.y
                LaserShot.Angle=Angle+180
   
                Dim time As Float
                time=500-465*streng
                
                LaserShot.Velocity_Y=-1.1*(Player.Y-desty)/time
                LaserShot.Velocity_X=1.1*(Player.X-destx)/time'
                LaserShot.Velocity=LaserShot.Velocity_Y   
                LaserShots.Add(LaserShot)'create new arrow object
'

'compute the angle and velocity (this code need to improve see video)
B4X:
LaserShot.Y=  LaserShot.Y + LaserShot.Velocity_y
LaserShot.x = LaserShot.X - LaserShot.Velocity_X
       

'with no gravity applied the arrow follows the correct angle of the applied velocity  
           fall = fall - Elapsed
            If fall<0  Then      
                LaserShot.Velocity_Y=LaserShot.Velocity_Y+1dip
                fall=100                          
            End If
            LaserShot.Angle=LaserShot.Angle + streng*9*(90+360 - LaserShot.Angle )/(90+360)

'render the arrow shape
B4X:
AC.SaveState
        AC.RotateCanvasAround(LaserShot.Angle,LaserShot.x,LaserShot.Y)
        AC.DrawBitmapAt(bmplaser(0),LaserShot.x,LaserShot.Y)
        AC.RestoreState
 
Last edited:

hookshy

Well-Known Member
Licensed User
Longtime User
I have not looked at the code of this:
I wanted to make the animation like in the bighunter game !!!
I want to make a hunt dino app for kids ....

I publish this stork hunting just because I have seen a comercial for a storke app ....
I said If i release some game with storke in the title I will get many installs ....stupid me
 

hookshy

Well-Known Member
Licensed User
Longtime User
Boring (always an elephant) and perhaps too violent for children.
To me boring is flapy birds and all games that ends with game over in 20 seconds

This game keeps you connected to get to the end ...
Its solid from programer point a view ...and becomes adictive
Has some nice features ...once you install there is great chance you will play this game (except you ofcourse )
This game has got to be loved with two simple actions ...press back to defend , release to throw arrow ! and some simple wepons store
No graphics needed in this game ...background has a moon that is all
 
Top