Hy all.
I want to make a game like a pacman. I can't make collision with wall, my hero always stop if collision with wall and can't moving again. But my hero work finely if collision with coin. Any idea?
Game Like Pacman
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Game Like Pacman
My first guess would be that you're penetrating the wall - you're moving inside it (probably so little you can't see it). And since you're now inside it, your collision detection algorithm is reporting a collision every frame, so you can't move along or back out of it. To fix that, you need to make sure your Pacman is "pushed back out" of the wall when you collide with it.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: Game Like Pacman
can you give me an example?
can i do it if i don't use "Physics" function?
I just use "graphics" function for make this game.
thanks.
can i do it if i don't use "Physics" function?
I just use "graphics" function for make this game.
thanks.
Re: Game Like Pacman
Somewhat off-topic. Just for fun and "inspiration"
http://www.royal-paw.com/games/netpack/
http://www.royal-paw.com/games/netpack/
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Game Like Pacman
You have to post your .love before I can tell you how to fix it.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Game Like Pacman
So many people are trying to make Pac-Man. A game that looks like Pac-Man is easy to make. A game that functions exactly like Pac-Man however, is not as easy.
I'll leave this here for your future use...
http://home.comcast.net/~jpittman2/pacm ... ssier.html
I'll leave this here for your future use...
http://home.comcast.net/~jpittman2/pacm ... ssier.html
Re: Game Like Pacman
this is my .love
thanks for all.- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Game Like Pacman
Alright, reviewing your code:
- First off, note that Pacman didn't use free movement, rather, it had a tile-based movement system. A free movement system like yours is fine, though. My primary warning would be to make sure it's easy to move the jebleh through "doorway" formations (and not get stuck on the blok corners)
- Part of your collision oddity is due to you using circular collision (checking only the distance between objects) on a grid-based world. The other part is due to the distance you move the jebleh when you touched a wall. The distance you should move back it is half of the size of jebleh plus half of the size of a blok.
- Here's revised collision code which works much more like what you're looking for. Simply replace what you have with this. It's a little bit odd still, but that's due to things like how you draw your graphics off-center. It's fixable with some number tweaking.
PS) Indonesian? Your English is pretty good. Not perfect, but quite understandable.
- First off, note that Pacman didn't use free movement, rather, it had a tile-based movement system. A free movement system like yours is fine, though. My primary warning would be to make sure it's easy to move the jebleh through "doorway" formations (and not get stuck on the blok corners)
- Part of your collision oddity is due to you using circular collision (checking only the distance between objects) on a grid-based world. The other part is due to the distance you move the jebleh when you touched a wall. The distance you should move back it is half of the size of jebleh plus half of the size of a blok.
- Here's revised collision code which works much more like what you're looking for. Simply replace what you have with this. It's a little bit odd still, but that's due to things like how you draw your graphics off-center. It's fixable with some number tweaking.
Code: Select all
if love.keyboard.isDown('up') then
fungsijebleh.Posisi.y = fungsijebleh.Posisi.y - jeblehspeed * dt
if fungsijebleh.Posisi.y < 25 then
fungsijebleh.Posisi.y = 25
end
for z,i in pairs(fungsiblok) do
local a,b,as,bs = fungsijebleh.Posisi, i.Posisi, jeblehsize/2, bloksize/2
if a.x-as < b.x+bs and a.x+as > b.x-bs and a.y-as < b.y+bs and a.y+as > b.y-bs then
fungsijebleh.Posisi.y = b.y + as + bs
end
end
end
if love.keyboard.isDown('down') then
fungsijebleh.Posisi.y = fungsijebleh.Posisi.y + jeblehspeed * dt
if fungsijebleh.Posisi.y > height - 35 then
fungsijebleh.Posisi.y = height - 35
end
for z,i in pairs(fungsiblok) do
local a,b,as,bs = fungsijebleh.Posisi, i.Posisi, jeblehsize/2, bloksize/2
if a.x-as < b.x+bs and a.x+as > b.x-bs and a.y-as < b.y+bs and a.y+as > b.y-bs then
fungsijebleh.Posisi.y = b.y - as - bs
end
end
end
if love.keyboard.isDown('left') then
fungsijebleh.Posisi.x = fungsijebleh.Posisi.x - jeblehspeed * dt
if fungsijebleh.Posisi.x < 25 then
fungsijebleh.Posisi.x = 25
end
for z,i in pairs(fungsiblok) do
local a,b,as,bs = fungsijebleh.Posisi, i.Posisi, jeblehsize/2, bloksize/2
if a.x-as < b.x+bs and a.x+as > b.x-bs and a.y-as < b.y+bs and a.y+as > b.y-bs then
fungsijebleh.Posisi.x = b.x + as + bs
end
end
end
if love.keyboard.isDown('right') then
fungsijebleh.Posisi.x = fungsijebleh.Posisi.x + jeblehspeed * dt
if fungsijebleh.Posisi.x > width - 35 then
fungsijebleh.Posisi.x = width - 35
end
for z,i in pairs(fungsiblok) do
local a,b,as,bs = fungsijebleh.Posisi, i.Posisi, jeblehsize/2, bloksize/2
if a.x-as < b.x+bs and a.x+as > b.x-bs and a.y-as < b.y+bs and a.y+as > b.y-bs then
fungsijebleh.Posisi.x = b.x - as - bs
end
end
end
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: Game Like Pacman
Taehl wrote:Alright, reviewing your code:
- First off, note that Pacman didn't use free movement, rather, it had a tile-based movement system. A free movement system like yours is fine, though. My primary warning would be to make sure it's easy to move the jebleh through "doorway" formations (and not get stuck on the blok corners)
- Part of your collision oddity is due to you using circular collision (checking only the distance between objects) on a grid-based world. The other part is due to the distance you move the jebleh when you touched a wall. The distance you should move back it is half of the size of jebleh plus half of the size of a blok.
- Here's revised collision code which works much more like what you're looking for. Simply replace what you have with this. It's a little bit odd still, but that's due to things like how you draw your graphics off-center. It's fixable with some number tweaking.PS) Indonesian? Your English is pretty good. Not perfect, but quite understandable.Code: Select all
if love.keyboard.isDown('up') then fungsijebleh.Posisi.y = fungsijebleh.Posisi.y - jeblehspeed * dt if fungsijebleh.Posisi.y < 25 then fungsijebleh.Posisi.y = 25 end for z,i in pairs(fungsiblok) do local a,b,as,bs = fungsijebleh.Posisi, i.Posisi, jeblehsize/2, bloksize/2 if a.x-as < b.x+bs and a.x+as > b.x-bs and a.y-as < b.y+bs and a.y+as > b.y-bs then fungsijebleh.Posisi.y = b.y + as + bs end end end if love.keyboard.isDown('down') then fungsijebleh.Posisi.y = fungsijebleh.Posisi.y + jeblehspeed * dt if fungsijebleh.Posisi.y > height - 35 then fungsijebleh.Posisi.y = height - 35 end for z,i in pairs(fungsiblok) do local a,b,as,bs = fungsijebleh.Posisi, i.Posisi, jeblehsize/2, bloksize/2 if a.x-as < b.x+bs and a.x+as > b.x-bs and a.y-as < b.y+bs and a.y+as > b.y-bs then fungsijebleh.Posisi.y = b.y - as - bs end end end if love.keyboard.isDown('left') then fungsijebleh.Posisi.x = fungsijebleh.Posisi.x - jeblehspeed * dt if fungsijebleh.Posisi.x < 25 then fungsijebleh.Posisi.x = 25 end for z,i in pairs(fungsiblok) do local a,b,as,bs = fungsijebleh.Posisi, i.Posisi, jeblehsize/2, bloksize/2 if a.x-as < b.x+bs and a.x+as > b.x-bs and a.y-as < b.y+bs and a.y+as > b.y-bs then fungsijebleh.Posisi.x = b.x + as + bs end end end if love.keyboard.isDown('right') then fungsijebleh.Posisi.x = fungsijebleh.Posisi.x + jeblehspeed * dt if fungsijebleh.Posisi.x > width - 35 then fungsijebleh.Posisi.x = width - 35 end for z,i in pairs(fungsiblok) do local a,b,as,bs = fungsijebleh.Posisi, i.Posisi, jeblehsize/2, bloksize/2 if a.x-as < b.x+bs and a.x+as > b.x-bs and a.y-as < b.y+bs and a.y+as > b.y-bs then fungsijebleh.Posisi.x = b.x - as - bs end end end
Hey it's work. thanks Taehl.
Nice to have shared with you.
It's first time i used Lua and Love Emulator, and maybe i love it. LOL
Oh yeah i'm Indonesian. I'm so sorry about my English.
Who is online
Users browsing this forum: No registered users and 8 guests