Gridlocked maze game[solved]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
zhaska
Prole
Posts: 3
Joined: Fri Apr 05, 2013 7:28 am

Gridlocked maze game[solved]

Post by zhaska »

Hi, I am just finishing up my first gridlocked "maze game" How can i make "exit" (draw image or just play sound)
or change map when player reaches "exit grid" (which has value 2) ?
map1 = {
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
{ 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1 },
{ 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1 },
{ 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1 },
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1 },
}

-Thanks in advance.


https://www.love2d.org/wiki/Tutorial:Gridlocked_Player
Last edited by zhaska on Sun Apr 07, 2013 7:54 pm, edited 2 times in total.
Level 2 dynamic scrambler.
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Gridlocked maze game/.help needed

Post by veethree »

If i understood your questions right, Here's how to do those things.

To make the game exit you call this:

Code: Select all

love.event.push("quit")
You could put this under love.keypressed so the game closes when you press escape or something like that.

To change the map when the player enters the 2 tile isn't too hard either, I could help you more if you showed me your .love file though.
But basically you first figure out what tile the player is on, Then you check if said tile is the type "2", If it is you change the map.
zhaska
Prole
Posts: 3
Joined: Fri Apr 05, 2013 7:28 am

Re: Gridlocked maze game/.help needed

Post by zhaska »

My point was how to make a code that detects player's presence in grid which has value of 2 and prints out pic and plays a sound :)

for example ..

if "player location value" == 2 then
love.audio.play(bgm2)
love.graphics.draw(image2 0, 0)
end

p.s please mute your sounds if you decide to run the program.
Last edited by zhaska on Sun Apr 07, 2013 7:56 pm, edited 2 times in total.
Level 2 dynamic scrambler.
Jackim
Prole
Posts: 12
Joined: Wed Apr 03, 2013 3:02 am
Location: Canada

Re: Gridlocked maze game/.help needed

Post by Jackim »

It seems like that tutorial gives you exactly what you need.

Code: Select all

function testMap(x, y)
    if map[(player.grid_y / 32) + y][(player.grid_x / 32) + x] == 1 then
        return false
    end
    return true
end
Change that to:

Code: Select all

function testMap(x, y)
    if map[(player.grid_y / 32) + y][(player.grid_x / 32) + x] == 2 then
        love.audio.play(bgm2)
        love.graphics.draw(image2, 0, 0)
    end
    return true
end
zhaska
Prole
Posts: 3
Joined: Fri Apr 05, 2013 7:28 am

Re: Gridlocked maze game /CaseClosed

Post by zhaska »

Damn .. the answer was just right front of me. Thanks for the info : D
Level 2 dynamic scrambler.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 8 guests