Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (794) Games in Android Showcase (234) games submitted by our members Games in WIP (864) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 How to define spline shape for 2D game  (Read 643 times) 0 Members and 1 Guest are viewing this topic.
MossyForest

Junior Devvie

Medals: 4
Exp: 1 year

 « Posted 2019-04-03 05:23:04 »

I'm currently making 2d game with libgdx and I need to make 'Beam Attack'

(image is from other game, and this is what I'm trying to achieve)

I'm not certain what is right term to call this shape.(concave curve? spline with height? spline with area?) Which is one of main reason I'm having hard time searching for how to handle this.

Someone told me there is 'Catmullâ€“Rom spline' which helps how to interpolate points and generate spline. But as this shape need to be used as 'attack' the shape can't be just line and need to be polygon that have area for hitbox. I've tried to using points Perpendicular to each point of spline or use same spline as other edge, but it didn't worked out.

So I have two questions.
1.Is there any better term to describe this shape rather than just spline?
2.How does this polygon's points should be defined to have right hitbox?
hekras
 « Reply #1 - Posted 2019-04-03 05:59:29 »

You could achieve what you want with a sine curve where you adjust the frequency and amplitude.

Something like

moveto(0,0)
for x = 0 to 1000
a = 100 * sin( x * pi / 1000)
y = a * sin( x * 2 * pi/100)
lineto(x,y)
endfor

(Did not test it myself yet, but I think it should work)
MossyForest

Junior Devvie

Medals: 4
Exp: 1 year

 « Reply #2 - Posted 2019-04-03 06:19:23 »

Thank you for the reply. but that isn't exactly what I need.
I'm fine with making 'line' of curves which catmull-rom can work out.
Where I'm having trouble is making those line of curves into actual polygon with area.
LiquidNitrogen
 « Reply #3 - Posted 2019-04-03 07:39:53 »

There's a Polyline class in libgdx, i cant see whether it does what you want, but googling how to make polylines gave some results when I tried to make something similar.
MossyForest

Junior Devvie

Medals: 4
Exp: 1 year

 « Reply #4 - Posted 2019-04-05 17:11:26 »

Thanks! I'm still having minor problems but googling polyline helped me a lot.
Pages: [1]
 ignore  |  Print

 hadezbladez (3181 views) 2018-11-16 13:46:03 hadezbladez (1151 views) 2018-11-16 13:41:33 hadezbladez (3151 views) 2018-11-16 13:35:35 hadezbladez (629 views) 2018-11-16 13:32:03 EgonOlsen (3918 views) 2018-06-10 19:43:48 EgonOlsen (4402 views) 2018-06-10 19:43:44 EgonOlsen (2622 views) 2018-06-10 19:43:20 DesertCoockie (3441 views) 2018-05-13 18:23:11 nelsongames (3573 views) 2018-04-24 18:15:36 nelsongames (4620 views) 2018-04-24 18:14:32
 Java Gaming Resourcesby philfrei2019-05-14 16:15:13Deployment and Packagingby philfrei2019-05-08 15:15:36Deployment and Packagingby philfrei2019-05-08 15:13:34Deployment and Packagingby philfrei2019-02-17 20:25:53Deployment and Packagingby mudlee2018-08-22 18:09:50Java Gaming Resourcesby gouessej2018-08-22 08:19:41Deployment and Packagingby gouessej2018-08-22 08:04:08Deployment and Packagingby gouessej2018-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