My Adventure Game Engine - Making Way For Adventure Engine 2
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: My Adventure Game Engine (NEW DEMO ON PAGE 20! 6/17/10)
Nah. It's working perfectly the way I have it now. I just need to clean up the code and fix some collisions that used to depend on an actor's Y being the top-left corner (It's now the bottom-left to simulate standing at ground level and help sorting correctly) and I can have a working demo. I also want to do some tweaking to the demo maps first too. Maybe tomorrow night I'll have a demo for you all.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: My Adventure Game Engine (NEW DEMO ON PAGE 20! 6/17/10)
Yay!Jasoco wrote:Maybe tomorrow night I'll have a demo for you all.
Help us help you: attach a .love.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: My Adventure Game Engine (NEW DEMO ON PAGE 20! 6/17/10)
Is there any way to sort by two key=value pairs? Like could I sort by Y then by X?
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: My Adventure Game Engine (NEW DEMO ON PAGE 20! 6/17/10)
Sure, if you make your comparison function smart enough.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: My Adventure Game Engine (NEW DEMO ON PAGE 20! 6/17/10)
reference: http://www.lua.org/pil/19.3.htmlJasoco wrote:Is there any way to sort by two key=value pairs? Like could I sort by Y then by X?
I'm going to assume that your table is called "elements " and it has a list of tables, each with attributes called ".x" and ".y". Also, take into account that I'm using Y just like LÖVE sorts it ("Up" items first). Adapt as needed:
Code: Select all
-- sorts by Y, then by X
function sortByPosition(elem1, elem2)
if(elem1.y > elem2.y) then return true end
if(elem1.x > elem2.x) then return true end
return false
end
...
-- assuming that your table is called "elements"
table.sort(elements, sortByPosition)
Here's a tighter sortByPosition function (does the same as above)
Code: Select all
function sortByPosition(elem1, elem2)
return elem1.y > elem2.y and true or elem1.x > elem2.x and true or false
end
When I write def I mean function.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: My Adventure Game Engine (NEW DEMO ON PAGE 20! 6/17/10)
Not quite. If you read the reference, you'll see that the sort function is supposed to do <, not >.kikito wrote:Code: Select all
function sortByPosition(elem1, elem2) return elem1.y > elem2.y and true or elem1.x > elem2.x and true or false end
Your code would cause the table to be sorted in reverse, and all things on bottom to be drawn first.
EDIT: also, you complicated things
This:
Code: Select all
function sortByPosition(elem1, elem2)
return elem1.y < elem2.y and true or elem1.x < elem2.x and true or false
end
Code: Select all
function sortByPosition(elem1, elem2)
return elem1.y < elem2.y or elem1.x < elem2.x
end
Help us help you: attach a .love.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: My Adventure Game Engine (NEW DEMO ON PAGE 20! 6/17/10)
Good point. Thanks.
When I write def I mean function.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: My Adventure Game Engine (NEW DEMO ON PAGE 20! 6/17/10)
Wait, wait, wait. We were both wrong. Let's examine what happens here:
You'd need something like:
Code: Select all
s = sortByPosition --shortcut
s({y = 1, x = 4}, {y = 2, x = 3}) --> true, good
s({y = 2, x = 4}, {y = 2, x = 3}) --> false, good
s({y = 3, x = 2}, {y = 2, x = 3}) --> true, *wrong*
Code: Select all
return elem1.y == elem2.y and elem1.x < elem2.x or elem1.y < elem2.y
Help us help you: attach a .love.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: My Adventure Game Engine (NEW DEMO ON PAGE 20! 6/17/10)
I have successfully integrated the Map Editor into the game itself! When the demo comes out, you will be able to access it by pressing E during the logo sequence. Right now it only edits map 1. But I plan on adding in a map list that you can choose from by the end of the day. If I don't, I'll let you know when I put the demo up. I will probably put the demo up bugs and all however it is right before I go to bed or by midnight Eastern or something. I dunno. Unless I make great progress in the next couple hours.
Back to work!
Back to work!
- nevon
- Commander of the Circuloids
- Posts: 938
- Joined: Thu Feb 14, 2008 8:25 pm
- Location: Stockholm, Sweden
- Contact:
Re: My Adventure Game Engine (NEW DEMO ON PAGE 20! 6/17/10)
It would be a lot easier and a lot more awesome if you would just put it up on some public VCS like (in order of preference ) Github, Gitorious, Sourceforge or whatever.
Who is online
Users browsing this forum: Ahrefs [Bot] and 5 guests