Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (799)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (865)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  How to code a sword swipe?  (Read 25545 times)
0 Members and 1 Guest are viewing this topic.
Offline Zeldar
« Reply #30 - Posted 2015-08-17 11:48:54 »

Yes that might work ! but does it works for all the cases?

For example if I want the first (outer) rotation to be far from the sword like O.x = x - 500 and O.y = y
And the second (inner) rotation to, not be in the middle of the sword, but at it's grip, something like O2.x = x + 40 and O2.y = y + 20

Should I do something like
1  
2  
O2.x = (xNew + O.x) / 2.0 + 40
O2.y = (yNew + O.y) / 2.0 + 20


to place it where I want ?

edit: the code in this message is false

Offline KaiHH

JGO Kernel


Medals: 764



« Reply #31 - Posted 2015-08-17 11:55:46 »

Yes that might work ! but does it works for all the cases?
Depends on what you mean by all cases. Smiley
I mean, the formula makes an assumption that the center of rotation for the second rotation is always halfway between O and 'B', because that was how it looked like in your image. If you were to rotate a point 'A' that is not the tip of the sword, then of course also the second rotation center will be different.
And if you choose anoter rotation center for the first/outer rotation, then also everything will be different.
The formula (A + B) / 2 is just used to find the center between A and B.
You can of course compute O2 however you like and make it depend on any other computed value or constant.
Offline Zeldar
« Reply #32 - Posted 2015-08-17 12:19:15 »

Ok I got it I modified the formula a bit to place the other centre points where I want  Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Zeldar
« Reply #33 - Posted 2015-08-17 12:56:52 »

Alright that's it! I can now translate, do multiple rotations with multitple centre points and everything works wonderfully!
Look at how amazing it looks even without any textures, these are just the polygons but it's so cool already Grin
Click to Play

Big thanks to everybody for the help ! Smiley
Offline KaiHH

JGO Kernel


Medals: 764



« Reply #34 - Posted 2015-08-17 13:06:10 »

Looks really nice! At some points it even looks like it's somehow 3D-ish. Smiley
Offline CelestialCreator
« Reply #35 - Posted 2015-08-17 13:57:30 »

Looks amazing! Does it work if you rotate the sword in the other direction?
Offline Zeldar
« Reply #36 - Posted 2015-08-17 14:38:01 »

Looks amazing! Does it work if you rotate the sword in the other direction?

I'm trying to implement this into my game to show every posibilities when it will be ready Smiley
Offline CelestialCreator
« Reply #37 - Posted 2015-08-17 15:00:22 »

I'm trying to implement this into my game to show every posibilities when it will be ready Smiley

Sounds spiffy. Can't wait to play the finished game! Cheesy
Offline Zeldar
« Reply #38 - Posted 2015-08-17 17:59:49 »

And here is the swipe system implemented to my game Cool ! Note that it is always active for the show and to make sure that it works for every movements, but in the real game it will be activated only when you are attacking Smiley

<a href="http://www.youtube.com/v/a2xhhLXGHTg?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/a2xhhLXGHTg?version=3&amp;hl=en_US&amp;start=</a>
Offline Archive
« Reply #39 - Posted 2015-08-18 02:54:32 »

It's amazing to witness someone in the world try hard and learn something.

Pages: 1 [2]
  ignore  |  Print  
 
 

 
Riven (189 views)
2019-09-04 15:33:17

hadezbladez (4875 views)
2018-11-16 13:46:03

hadezbladez (1790 views)
2018-11-16 13:41:33

hadezbladez (5147 views)
2018-11-16 13:35:35

hadezbladez (1018 views)
2018-11-16 13:32:03

EgonOlsen (4377 views)
2018-06-10 19:43:48

EgonOlsen (5220 views)
2018-06-10 19:43:44

EgonOlsen (2949 views)
2018-06-10 19:43:20

DesertCoockie (3868 views)
2018-05-13 18:23:11

nelsongames (4294 views)
2018-04-24 18:15:36
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!