Soo what now?

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.
Post Reply
KayleMaster
Party member
Posts: 234
Joined: Mon Aug 29, 2016 8:51 am

Soo what now?

Post by KayleMaster »

I've done my terrain engine, I've never actually gotten this far because of game maker (I was trying so hard to optimize I ran in all kinds of walls, walls that don't exist in Love2D) so I'm not sure what's the next step.
I want units, but how exactly would I approach this? Do I have to adopt some kind of OOP ? Any ideas/tips?
marco.lizza
Citizen
Posts: 52
Joined: Wed Dec 23, 2015 4:03 pm

Re: Soo what now?

Post by marco.lizza »

Do I have to adopt some kind of OOP ?
Not necessarily. An entity functional mixin-based model would be more than enough.
KayleMaster
Party member
Posts: 234
Joined: Mon Aug 29, 2016 8:51 am

Re: Soo what now?

Post by KayleMaster »

entity functional mixin-based model

Yes, yes.... I know some of these words.
EDIT: are you referring to something like this : https://www.reddit.com/r/gamedev/commen ... nd_mixins/
marco.lizza
Citizen
Posts: 52
Joined: Wed Dec 23, 2015 4:03 pm

Re: Soo what now?

Post by marco.lizza »

Yes, the approach I suggest is similiar to this. However, keep in mind that you don't necessarily need to incorporate a full-fledged abstraction model and/or library.
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Soo what now?

Post by Inny »

Lua's tables are "Duck Typed", as in "If it looks like a duck and walks like a duck, it is a duck." What's becoming all the rage these days are "Entity Component Systems" where you write your code to do some basic level inspection of the tables passed to it in order to determine which code applies to it.

To put it another way, let's say you're making a 2d platformer. Some things will be affected by gravity (like the player), and some things will not (like powerups). The player entity would have a property that says gravity affects it, and the code to apply gravity would check for gravity, and check for the Y position. That would look like this:

Code: Select all

function run_gravity_system(entities)
  for i, entity in ipairs(entities) do
    if entity.gravity and entity.Y then
      entity.Y = entity.Y + entity.gravity
    end
  end
end
In this way, you can always add or remove gravity from any entity in your world.

(Of course, gravity as presented here is not very good, you'd want a deltaY property and some other math going on.)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 13 guests