## My Adventure Game Engine - Making Way For Adventure Engine 2

Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

### Re: My Zelda style adventure engine (DEMO NOW AVAILABLE)

anjo wrote:
Jasoco wrote:Question though, can I place a TTF file inside the .love and use that as my font if I want something fancier?
Yes. Yes you can.
Is there a syntax? Well of course there is, what would it be? And can the font be in a sub-folder?
Jasoco wrote:

Code: Select all

love.graphics.draws(imageDef, sx, sy, ix, iy, w, h)
Where sx/sy is the location on screen, ix/iy is where in the image to crop, and w/h is the size of the crop. I don't get what Quads means. Simply put, what do I replace the above with to achieve the same result of a portion of an image drawn in a specific place on screen?

Code: Select all

local q = love.graphics.newQuad(ix, iy, w, h, imageDef:getWidth(), imageDef:getHeight())
love.graphics.drawq(imageDef, q, sx, sy)
So wait, do I have to define a new quad for every tile? If I have to, can I place a quad into an array? Since I would have many many tiles, I'd want a multi-dimentional array of tiles. imageDef[1][1] for instance which would be a single tile. Before I would just define imageDef with love.graphics.newImage then use love.graphics.draws to draw out a portion. Now it seems I have to know ahead of time all the portions I will need to draw? As long as I can place all the defs inside an array, and have it be multi-dimensional (I don't want to have to place all my tiles in a straight line.)

Edit: What about spriteBatch? How would I use that? Would that be the answer?
Jasoco wrote:What I need first is to know how I make my own main loop. I heard you can do this now and saw code for it but do not remember where. Or will the old load, update and draw functions work fine? I heard making your own main loop was more flexible though.
You make your own main loop by overriding love.run() - you can see the default here. The default functions the same as 0.5.0's main loop, though, so love.load, love.update, and love.draw will all work fine even if you don't touch love.run.
I see how it works now. 0.6.0 gives us the option for finer control if we want it. Or plain old simpleness if we so choose.

bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

### Re: My Zelda style adventure engine (DEMO NOW AVAILABLE)

Jasoco wrote:what would it be? And can the font be in a sub-folder?

Code: Select all

ttfFont = love.graphics.newFont("path/to/font.ttf")
love.graphics.setFont(ttfFont)
You can also call setFont directly with the filepath, but that's not a great idea if you're going to be changing the font every frame.
Jasoco wrote:So wait, do I have to define a new quad for every tile? If I have to, can I place a quad into an array? Since I would have many many tiles, I'd want a multi-dimentional array of tiles. imageDef[1][1] for instance which would be a single tile. Before I would just define imageDef with love.graphics.newImage then use love.graphics.draws to draw out a portion. Now it seems I have to know ahead of time all the portions I will need to draw? As long as I can place all the defs inside an array, and have it be multi-dimensional (I don't want to have to place all my tiles in a straight line.)
As per the docs, Quad objects have a :setViewport(x, y, w, h) method you can use. You would create one Quad for the tilesheet (the whole Image), and then change the viewport depending on what tile you want to draw. Assuming each tile is the same size, you'd just need to store the coordinates of each tile image (within the tilesheet), and then set the viewport accordingly. Since you already have the coordinates for use with love.graphics.draws, you should be fine.
Jasoco wrote:Edit: What about spriteBatch? How would I use that? Would that be the answer?
I haven't used SpriteBatch myself at all, so I'm not going to be able to provide a code example with any confidence, but here's how it works. Create a SpriteBatch using the tilesheet Image (and set an appropriate max number of tiles), and then use SpriteBatch:addq to add a Quad. You only need one Quad, still - set the viewport for a given tile, call addq with the relevant arguments, repeat for as many tiles as you like. Then, just draw the SpriteBatch with love.graphics.draw and all the tiles will get drawn in at once (thanks, VBOs!).

EDIT: I still recommend IRC. You don't even have to install anything, just use freenode's web client.

Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

### Re: My Zelda style adventure engine (DEMO NOW AVAILABLE)

Next time I get a day to sit down and spend all day on this I will go on IRC. Hopefully you'll be available at the time. We'll hammer it all out.

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: My Zelda style adventure engine (DEMO NOW AVAILABLE)

Now you got me thinking... I could probably write a small utility script that points out everything that needs to be changed. Will post it on the forum if I get it working.

EDIT: I now have a 75 line script that catches a large number of changes, I will look for some other changes to spot, and then upload it to the forum.
EDIT2: I have it up at http://love2d.org/forum/viewtopic.php?f ... 473#p11473

Avalon
Prole
Posts: 49
Joined: Sat Sep 12, 2009 11:37 am

### Re: My Zelda style adventure engine (DEMO NOW AVAILABLE)

This works fine.

Code: Select all

        -- Add to sprite buffer.

-- Draw sprite buffer.
love.graphics.draw(tileset.sb, 0, 0)

-- Clear sprite buffer.
tileset.sb:clear()

Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

### Re: My Zelda style adventure engine (DEMO NOW AVAILABLE)

While I haven't converted to 0.6.0 yet, I have done some significant work on my engine in the past few weeks. Some new changes include:

Fading in and out between maps. This was a lot of work since I had to create artificial delays before loading the map then fade it back up when loaded. Still buggy though. Pain in the ass.

A new setTimeOut() function creates JavaScript-like timeouts for offsetting the loading of functions to however many seconds you want to wait. Right now it's limited to a function name, no parameters, and you can't just put code in there to execute later. I can't figure out if there's a better way to have Lua delay the execution of code. If there is, I'd love to know. I currently use the delay to artificially delat the starting of a game from when you exit the menu to when the game loads. Since loading is instant, delaying gives the player time to rest. TimeOuts will probably also come in handy with some scripting.

Code: Select all

timeOut = {}
timeOutSet = {}
setTimeOut(seconds, function_name, unique_id)

function setTimeOut(d,c,n)
if timeOutSet[n] ~= true then
d = d + love.timer.getTime()
table.insert(timeOut, { id = n, delay = d, callback = c } )
timeOutSet[n] = true
end
end

function updateTimeOut()
local a = love.timer.getTime()
for i, t in ipairs(timeOut) do
if a >= t.delay then
local cb = t.callback()
timeOutSet[t.id] = false
table.remove(timeOut, i)
end
end
end

Cinematic mode. In a lot of modern games, when the player starts a cinematic script, i.e. talks to a major character for a while, black bars slide on screen to give the game a more movie-like look and signify that the player is learning more about his main quest. I have implemented a really nice version of this. It looks really nice with the major script in the demo, where one girl gets mad at the other. Makes it feel more like a movie. Like watching a story unfold. When initiated, the status area slides down off screen and the bars slide into view.

A more pixel-like design for on-screen text and talk bubbles.

I'm aiming for more of a doubled-up pixelated look like Cave Story and so many other 16-bit styled indie games these days. Rather than creating higher detailed 32x32 pixel images, it'll be easier to make 16x16 and double them up.

And yes, the trees still look crappy. Sorry.

I am very happy with how this is working out. Slowly but surely the engine is taking shape.

In this shot you see the cinematic bars, the pixelated text and balloons, 640x480 4:3 mode (As opposed to 800x500 16:10 mode) and the crappy trees.

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: My Zelda style adventure engine (DEMO NOW AVAILABLE)

Jasoco wrote:crappy trees
But... I like them...

Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

### Re: My Zelda style adventure engine (DEMO NOW AVAILABLE)

They're too plain. And look terrible in a repeating pattern. I'm working on new trees. I think I figured out a method that works.

bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

### Re: My Zelda style adventure engine (DEMO NOW AVAILABLE)

I wonder why there's one tree in there that looks different. (above the health bar, if you hadn't noticed)

Virox
Citizen
Posts: 64
Joined: Thu Jan 07, 2010 6:24 pm

### Re: My Zelda style adventure engine (DEMO NOW AVAILABLE)

bartbes wrote:I wonder why there's one tree in there that looks different. (above the health bar, if you hadn't noticed)
actually there are 3 of those

@Jasoco: Maybe if you randomly use 3 different big trees it will break the pattern even more. But it looks nice already

### Who is online

Users browsing this forum: No registered users and 12 guests