Arrow throwing

Discussion in 'Game Development' started by hookshy, Jun 18, 2018.

  1. hookshy

    hookshy Well-Known Member Licensed 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)
    Code:
    '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
    Code:
    '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
    Code:
    streng = Sqrt(Power(Abs(Player.x - xf),2) + Power(Abs(Player.Y - yf),2))/(Activity.Height-Player.Y)
    'create new arrow and shot
    Code:
    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)
    Code:
    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
    Code:
    AC.SaveState
            AC.RotateCanvasAround(LaserShot.Angle,LaserShot.x,LaserShot.Y)
            AC.DrawBitmapAt(bmplaser(
    0),LaserShot.x,LaserShot.Y)
            AC.RestoreState
     
    Last edited: Jun 18, 2018
    Peter Simpson, Beja, JordiCP and 4 others like this.
  2. hookshy

    hookshy Well-Known Member Licensed User

  3. LucaMs

    LucaMs Expert Licensed User

  4. hookshy

    hookshy Well-Known Member Licensed User

    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
     
    LucaMs likes this.
  5. LucaMs

    LucaMs Expert Licensed User

    This one?



    Boring (always an elephant) and perhaps too violent for children.
     
  6. hookshy

    hookshy Well-Known Member Licensed User

    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
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice