Hi, I've been coding a basic top down shooter for my computing project at my sixth form. Currently the current state is on github. https://github.com/TeshiV/Game
Ok the trouble im having is, ive just tried to implement a camera system, which works! But its resulted in the bullet firing being... messed up i guess. I think i understand whats going on but i dont know how to go about fixing it, if someone could point me in the right direction I would be very greatful. I think that whats happening is the mouse x and y positions dont change when i move but obviously the player's position changes so i think this is causing the problem with shooting. Sorry if what ive said is confusing :s
First time coding a game, hit a wall
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: First time coding a game, hit a wall
You are right. You need to convert the mouse coords to world coords. Maybe adding the the x and y of the top left of your camera to the mouse coords. So maybe
Code: Select all
function toWorldCoords(x,y)
x = x + (cameraX-love.graphics.getWidth()/2)
y = y + (cameraY-love.graphics.getHeight()/2)
return x,y
end
Re: First time coding a game, hit a wall
Thanks! I managed to fix it using your suggestion with a tweak, instead of (cameraX - love.graphics.getWidth()/2) etc i just did
x = x + cameraX etc
x = x + cameraX etc
Who is online
Users browsing this forum: No registered users and 2 guests