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?
Soo what now?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Citizen
- Posts: 52
- Joined: Wed Dec 23, 2015 4:03 pm
Re: Soo what now?
Not necessarily. An entity functional mixin-based model would be more than enough.Do I have to adopt some kind of OOP ?
-
- Party member
- Posts: 234
- Joined: Mon Aug 29, 2016 8:51 am
Re: Soo what now?
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/
-
- Citizen
- Posts: 52
- Joined: Wed Dec 23, 2015 4:03 pm
Re: Soo what now?
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.
Re: Soo what now?
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:
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.)
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
(Of course, gravity as presented here is not very good, you'd want a deltaY property and some other math going on.)
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 11 guests