Page 4 of 4

Re: LÖVElike - A Roguelike Engine (aka "Barrelike") -Abandon

Posted: Tue Oct 19, 2010 7:53 am
by arquivista
smiller wrote:Thank you very much! This was useful! I am adding onto this to create my game. I loved how I was just able to change the tile size and everything still worked. I think someone once described this to me as having "no magic numbers". Very easily changeable.

I won't rely on it too heftily... soon it will be something of it's own. :)
I'm glad that this helped or served someone. The "engine" was a bit preliminary but since the beginning tried to make the map, the mobs and so on the most easily configurable/changeable. Good luck with the project, and keep us informed.

Re: LÖVElike - A Roguelike Engine (aka "Barrelike") -Abandon

Posted: Sat Oct 23, 2010 7:49 pm
by smiller
arquivista wrote:
smiller wrote:Thank you very much! This was useful! I am adding onto this to create my game. I loved how I was just able to change the tile size and everything still worked. I think someone once described this to me as having "no magic numbers". Very easily changeable.

I won't rely on it too heftily... soon it will be something of it's own. :)
I'm glad that this helped or served someone. The "engine" was a bit preliminary but since the beginning tried to make the map, the mobs and so on the most easily configurable/changeable. Good luck with the project, and keep us informed.
I noticed how it was working, but you put a note that the psuedo-camera window offsets (x and y) needed to be fixed. What's up with it that needs to be fixed? I can fix it myself, I am just more curious than anything.

Re: LÖVElike - A Roguelike Engine (aka "Barrelike") -Abandon

Posted: Sat Oct 23, 2010 10:03 pm
by arquivista
smiller wrote:I noticed how it was working, but you put a note that the psuedo-camera window offsets (x and y) needed to be fixed. What's up with it that needs to be fixed? I can fix it myself, I am just more curious than anything.
Thanks for talking about that smiller. I should have fixed that long ago. Offset is working now. Uploaded 0.54. Code and method is not what I wanted (I desire to put it even more simple) but at least offset is functioning now. Also increased a bit the map just to test auto-size window/info border and auto-center text.

The problem why wasn't really working is that since I simplified a bit the engine used in tutorial. So the LÖVElike engine wasn't working with the tutorial offset formula and I had to alter things but never succeed in putting things as I really wanted. Offset was badly implemented and was "dummy" code. It works properly now but I still would prefer to even simplify how things are done a little more.

Re: [RIP] LÖVElike - A Roguelike Engine ("Bärrelike" flavour

Posted: Mon Oct 25, 2010 1:21 am
by smiller
Also, just wondering, where in the heck in the code does it say where the map begins being drawn in the window? I can not for the life of me find where the map is being moved for the border to appear.

Re: [RIP] LÖVElike - A Roguelike Engine ("Bärrelike" flavour

Posted: Mon Oct 25, 2010 5:46 am
by arquivista
smiller wrote:Also, just wondering, where in the heck in the code does it say where the map begins being drawn in the window? I can not for the life of me find where the map is being moved for the border to appear.
The fast explanation:

"map.camera_offset_x" and "map.camera_offset_y". At the moment they have both value 32 thats puts the "camera map" 32 pixels away (in x and y axis) of the top left corner. Obvious if you put 0 in both you will put the "camera" at top left corner (x0,y0).

The detailled explanation:

You know this part for sure, but let's recap. The map is drawn in function draw_map(). In the "For" loop first draws every piece of map tiles according the pretended "map camera" size (camera_height, camera_width), then the hero and the mobs over the map. This is a realtime routine called endless when you are playing.

Since last version map area really starts draws (as it should) in default at x0,y0. However in function setupMap() you have 2 variables that pushes far you wants the coordinates where map loop starts drawing. That are the Offset variables "map.camera_offset_x" and "map.camera_offset_y" where as you see are both with valor 32 just for this engine demo create the border/margin area effect. Those values puts the beggining of map at x32,y32 (pixels). So as you can see the map don't starts at 0,0 but have a "border" of 32px giving space for the text values be drawn outside the map. (BTW: 32 was also chosen because is also the value of tile width and height). If you want to draw map instead at 0,0, (reset) or any other place in the window just need to alter that two offset values to the values in px you want. So with values "0" don't alter nothing. "Play" with those variables and you will see the difference.

Let's check the instruction that draws ONE piece of tile map inside the "for" loop (that draws all "map camera"):

Code: Select all

         love.graphics.draw( 
            tile.layer_low[map.data[y+map.y][x+map.x]], 
            (x*tile.w) - tile.w + map.camera_offset_x, 
            (y*tile.h) - tile.h + map.camera_offset_y)
The last 2 lines points where in X (first line) and Y (second line) the map tile is draw. See the "- tile.w/h + map.camera_offset_x/y" part? That makes the map draw closer or more distant that the For Loop values (x*tile.w, y*tile.h) it should do it. First the minus "tile.w/h" "compensates" making that the map is really draw having 0,0 as start reference but the plus "map.camera_offset_x/y" pushes every piece of tiles be draw x/y pixels distance from where it should be.

So map_offset_x/y are the magic numbers, put at 0,0 if you want that map starts at beggining of top-left corner of window, left it at 32,32 as I'm doing to create the border area or pushes farther in the window by putting a greater valour. It's your choice where the "map camera" starts to be drawn.

Note: In older version spite of value the offset variables weren't working well so the map was being draw starting at x32,y32 (spite offset value was 0) so that's why "offset" was broken. Now it does it at by default at 0,0 (as it should be).

I know that I explained more than you needed but that way I hope don't left on you any doubt.

Re: [RIP] LÖVElike - A Roguelike Engine ("Bärrelike" flavour

Posted: Sat Nov 20, 2010 9:38 pm
by arquivista
Small update uploaded:

0.055 - Null, Paused, Help and Quit states/modes added. Extended Movement added. Flag to switch Extended Movement on/off. Additional keys set added.

Re: [RIP] LÖVElike - A Roguelike Engine ("Bärrelike" flavour

Posted: Thu May 03, 2012 2:50 pm
by Davidobot
BE REBORN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :halloween: