I created my own game and when i tried adding the player image the collision went all crazy
im new to programming and im kinda noobish... so help me please
Collision not Working.. help me please
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Collision not Working.. help me please
Could you upload your game as a .love? See the wiki to learn how to make a .love.
Help us help you: attach a .love.
Re: Collision not Working.. help me please
There it is
Re: Collision not Working.. help me please
I found two thing that go wrong. First, the player is drawn with an offset (a bit too far right and down). To correct this, replace the drawing command by this:
Second, when you hit a wall on the left, you start floating/jumping. To fix this, change line 106 in your main.lua to
(add +1 in the end). After a collision with the left wall, the player was not put to the correct position, such that in the next frame, the up/down-collision found a collision and moved the player up.
You have to change line 78 (collision up/down) similarly to:
Code: Select all
love.graphics.draw(hero, player.x, player.y,0,1,1,player.w/2,player.h/2)
Code: Select all
self.x = nextX + map.tileWidth - ((nextX - halfX) % map.tileWidth)+1
You have to change line 78 (collision up/down) similarly to:
Code: Select all
self.y = nextY + map.tileHeight - ((nextY - halfY) % map.tileHeight)+1
Check out my blog on gamedev
Re: Collision not Working.. help me please
Thank you so much for the help, but i have a question.
I want to add enemies to my game aswell as a fire mechanic and score is there any tutorial out there for it?
I want to add enemies to my game aswell as a fire mechanic and score is there any tutorial out there for it?
Re: Collision not Working.. help me please
Here is a really neat tutorial: http://www.headchant.com/2010/12/31/lov ... 2-pew-pew/Pheeea wrote:Thank you so much for the help, but i have a question.
I want to add enemies to my game aswell as a fire mechanic and score is there any tutorial out there for it?
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
personal page and a raycaster
Re: Collision not Working.. help me please
next time use the right forum would you
Who is online
Users browsing this forum: No registered users and 5 guests