My Adventure Game Engine - Making Way For Adventure Engine 2

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
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)

Post by Jasoco »

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.
User avatar
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)

Post by Robin »

Jasoco wrote:Maybe tomorrow night I'll have a demo for you all.
Yay! :awesome:
Help us help you: attach a .love.
User avatar
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)

Post by Jasoco »

Is there any way to sort by two key=value pairs? Like could I sort by Y then by X?
User avatar
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)

Post by bartbes »

Sure, if you make your comparison function smart enough.
User avatar
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)

Post by kikito »

Jasoco wrote:Is there any way to sort by two key=value pairs? Like could I sort by Y then by X?
reference: http://www.lua.org/pil/19.3.html

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
I haven't tested this code, bugs might be lurking.
When I write def I mean function.
User avatar
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)

Post by Robin »

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
Not quite. If you read the reference, you'll see that the sort function is supposed to do <, not >.

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
is equivalent to

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.
User avatar
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)

Post by kikito »

Good point. Thanks.
When I write def I mean function.
User avatar
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)

Post by Robin »

Wait, wait, wait. We were both wrong. Let's examine what happens here:

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*
You'd need something like:

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.
User avatar
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)

Post by Jasoco »

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!
User avatar
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)

Post by nevon »

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 :P) Github, Gitorious, Sourceforge or whatever. :3
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest