## My Own Tile Based Game

Show off your games, demos and other (playable) creations.
steVeRoll
Party member
Posts: 125
Joined: Sun Feb 14, 2016 1:13 pm

### My Own Tile Based Game

It has walls, keys, lasers, switches... Uh... That's pretty much it. (And boxes, but they don't fully work yet)

Use the arrow keys to move. Collect all of the keys in the level to open the exit, then touch the exit to go to the next level. There might be lasers blocking your way, but you can disable them with their corresponding switch. To use a switch, walk over it and press [A].
Attachments
Keygame.love
Skeiks
Citizen
Posts: 51
Joined: Wed Jan 28, 2015 1:51 pm

### Re: My Own Tile Based Game

Well done so far, a couple of things though.

Could you make it so you can hold down a direction to keep moving in that direction? Having to press the arrow keys multiple times gets very tedious after a while.

When you're designing puzzles, if you go further with the game, I suggest making some switches activate more than one component. And also adding a switch type that activates as you pass through it, as opposed to when you press a button standing on it.
steVeRoll
Party member
Posts: 125
Joined: Sun Feb 14, 2016 1:13 pm

### Re: My Own Tile Based Game

Skeiks wrote:Well done so far, a couple of things though.

Could you make it so you can hold down a direction to keep moving in that direction? Having to press the arrow keys multiple times gets very tedious after a while.

When you're designing puzzles, if you go further with the game, I suggest making some switches activate more than one component. And also adding a switch type that activates as you pass through it, as opposed to when you press a button standing on it.
Thank you for your feedback, Skeiks! I'll try to implement all you said.
I could finish making these boxes and use them with the stand-on button mechanic you mentioned.
Again, thank you!
Xugro
Citizen
Posts: 90
Joined: Wed Sep 29, 2010 8:14 pm

### Re: My Own Tile Based Game

Works nicely.

I just looked at the code and noticed two things:
1. You reload a lot of images every time you use them. Just load them in love.load() and use them when you need them. You could use something like this:

Code: Select all

function love.load()
-- load all images once and save them
player.image["up"] = love.graphics.newImage("assets/player_up.png")
player.image["down"] = love.graphics.newImage("assets/player_down.png")
player.image["left"] = love.graphics.newImage("assets/player_left.png")
player.image["right"] = love.graphics.newImage("assets/player_right.png")

-- set starting direction
player.lastDirection = "down"
end

function love.draw()
-- just draw the appropriate image
love.graphics.draw(player.image[player.lastDirection], (player.x-1)*blockSize, (player.y-1)*blockSize)
end

2. Every time you load a level for every tile-type you look at every position. You could just look at every position once and then decide what do to with it - e.g.:

Code: Select all

function load_level()
for i=1,arrWidth do
for j=1,arrHeight do
if currLvlArr[i][j] == 3 then
position_player(i,j)
elseif currLvlArr[i][j] == 4 then
generate_key(i,j)
elseif
-- and so on
end
end
end
end


### Who is online

Users browsing this forum: No registered users and 15 guests