hookshy Well-Known Member Licensed User Longtime User Jun 18, 2018 #1 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: Copy '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: Copy '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: Copy streng = Sqrt(Power(Abs(Player.x - xf),2) + Power(Abs(Player.Y - yf),2))/(Activity.Height-Player.Y) 'create new arrow and shot Code: Copy 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: Copy 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: Copy 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
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: Copy '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: Copy '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: Copy streng = Sqrt(Power(Abs(Player.x - xf),2) + Power(Abs(Player.Y - yf),2))/(Activity.Height-Player.Y) 'create new arrow and shot Code: Copy 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: Copy 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: Copy AC.SaveState AC.RotateCanvasAround(LaserShot.Angle,LaserShot.x,LaserShot.Y) AC.DrawBitmapAt(bmplaser(0),LaserShot.x,LaserShot.Y) AC.RestoreState
hookshy Well-Known Member Licensed User Longtime User Jul 4, 2018 #2 Here is a sample game: https://play.google.com/store/apps/details?id=com.hunter.female
LucaMs Expert Licensed User Longtime User Jul 5, 2018 #3 Hi, @hookshy, your video is in the wrong orientation I have not looked at the code of this: https://www.b4x.com/android/forum/threads/archer-with-sources.77404/
Hi, @hookshy, your video is in the wrong orientation I have not looked at the code of this: https://www.b4x.com/android/forum/threads/archer-with-sources.77404/
hookshy Well-Known Member Licensed User Longtime User Jul 6, 2018 #4 LucaMs said: I have not looked at the code of this: Click to expand... 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 said: I have not looked at the code of this: Click to expand... 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 Expert Licensed User Longtime User Jul 6, 2018 #5 hookshy said: bighunter game Click to expand... This one? Boring (always an elephant) and perhaps too violent for children.
hookshy said: bighunter game Click to expand... This one? Boring (always an elephant) and perhaps too violent for children.
hookshy Well-Known Member Licensed User Longtime User Jul 7, 2018 #6 LucaMs said: Boring (always an elephant) and perhaps too violent for children. Click to expand... 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
LucaMs said: Boring (always an elephant) and perhaps too violent for children. Click to expand... 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