Noobie just discovered LOVE. Tips for a top down sports game?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
togFox
Party member
Posts: 774
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Noobie just discovered LOVE. Tips for a top down sports game?

Post by togFox »

I'm above average at LUA and I've been thinking about this new sports game for about 18 months. Can't shake it and it's time to make some concepts for play testing.

Discovered LOVE and flicked through the manual. LOVE has a physics engine which frankly, I never even thought about so that's fantastic!

I'm planning out a top down sports game. Think hockey - looking straight down. There will be a puck. Two teams. Physical objects moving around and bumping into each other.

This is day 1 and I'm going to love this journey. I'm not a noob programmer but I am noob to LOVE and it's libaries. Any early words of caution as I start this?

Cheers n beers.
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
togFox
Party member
Posts: 774
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: Noobie just discovered LOVE. Tips for a top down sports game?

Post by togFox »

I'm still reading lots. Can anyone suggest if I can or should use the different physics libraries? I'll have hockey players voicing of each other and the wall and whilst subjected to force and momentum they will have 'free' will to influence their movement and the game.

I'm currently setting up classes, properties and functions and intended to make my own physics (velocity/acceleration/mass/impulse/momentum) but if there is an easier way then I'll read up on that.
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Noobie just discovered LOVE. Tips for a top down sports game?

Post by ivan »

togFox wrote: Sat Jan 30, 2021 9:54 am Discovered LOVE and flicked through the manual. LOVE has a physics engine which frankly, I never even thought about so that's fantastic!
It's called box2d. love.physics is your best shot, but there is also bump.lua and my humble fizzx: https://github.com/2dengine/fizzx
togFox wrote: Sat Jan 30, 2021 9:54 am Any early words of caution as I start this?
The easy part is the physics. Use long edge shapes for the boundaries of the hockey ring. Restitution must be greater than 0 so that the puck can bounce around. Linear damping can be used on the puck so that it slows down gently. You will need sensor shapes for the goals.

The hard part will be the AI if you this is going to be player vs CPU. I suggest starting out with just two players locally, without any AI.
Last edited by ivan on Sat Dec 11, 2021 8:18 am, edited 1 time in total.
User avatar
togFox
Party member
Posts: 774
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: Noobie just discovered LOVE. Tips for a top down sports game?

Post by togFox »

So I'm thinking out loud, remembering this is day 2 in my Love2D journey, that I want a bunch of physics bodies. These are AI. They have their own mind/will/actions and will execute those 'normal' movements with Body:applyLinearImpulse and let the physics engine deal with collisions and rebounds etc.

Yes? On the right track? Or no. :(

Edit: ... overhead action games. [FIZZX] THANKS!!
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Noobie just discovered LOVE. Tips for a top down sports game?

Post by ivan »

togFox wrote: Sun Jan 31, 2021 1:00 pm I want a bunch of physics bodies.
With love.physics one body can have multiple shapes/fixtures, therefore you could just use one "ground" body for everything static.
togFox wrote: Sun Jan 31, 2021 1:00 pm These are AI. They have their own mind/will/actions
The AI will have to figure out how to move these bodies and where to apply forces.
Like I said, this can be very complicated so you probably want to start with local multiplayer.
User avatar
togFox
Party member
Posts: 774
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: Noobie just discovered LOVE. Tips for a top down sports game?

Post by togFox »

I'm quite comfortable with the math and vectors and angular velocities for determining who needs to move where. I already have four love.graphic.draw.circles chasing each other around the screen as an exercise. These are driven with a class I made up called 'hockeyplayer'.

I guess i was asking if should I use ''applyLinearForce' to make an AI object move in a known direction to make that body move towards that direction and let love.physics deal with momentum, collisions and rebounds?

After a contact, the AI would evaluate its new positron and then apply an adjusted linear force to try to complete its goal.

Is ApplyLinearForce the best method for my AI controlled hockey players?

Edit: apply force might be better. I'll read some more!
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Noobie just discovered LOVE. Tips for a top down sports game?

Post by ivan »

ApplyForce should be called every frame over longer periods of time (for example: jetpacks, cars, etc) whereas applyImpulse is used once for (more-or-less) instant changes in velocity (jumping or throwing projectiles).
Read up a little bit on Newtonian physics and in particular the following two formulas:
Impulse = change in velocity * mass (instant change in velocity)
Force = mass * acceleration (acceleration or change in velocity over time)

Like I said, AI is a difficult subject, so I can't really help much beyond that.
User avatar
togFox
Party member
Posts: 774
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: Noobie just discovered LOVE. Tips for a top down sports game?

Post by togFox »

Thanks. I think I need to apply force to the AI and apply impulse to the puck.

I think at this point I need to stop reading and experiment. Thanks.
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
togFox
Party member
Posts: 774
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: Noobie just discovered LOVE. Tips for a top down sports game?

Post by togFox »

Just celebrating my game is functional. Not pretty, but functional. :)

In just over a week Love2d has allowed me to make a playable concept of a sports field full of bodies moving around and reacting via Newtonian physics. :)

Appreciate the tips. Onwards and upwards.
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 20 guests