Re: A very simple camera lib
Posted: Sat May 03, 2014 1:00 am
Hi,
I know this is an old thread, but seeing as it is about this library I thought it okay : )
I am running into a problem that my inexperienced mind cant figure out.
Here is what I have:
A player that moves with the camera. Can move around freely without affecting what the camera looks at.
The camera moves at a steady rate of 15 * dt upwards.
I have enemies that move independently of the camera - that shoot at the player.
I cant figure out how to have the bullets from the independent enemies, target the player. Either the bullets (from a "tank") appear from the middle of the screen, or if I switch it up, the bullets target an area just above the player (but appear at the tank). The bullets are "heatseekers" so they follow the player around.
I know that I need to account for the fact that the tanks and its bullets are using the coordinates for the whole world, and that the player coordinates are within the fixed viewport of the camera. But I cant seem to figure it out. I have spent just over 4 hours trying to find a solution - but I believe that the solution is very simple - I just cant "see" it yet.
If I add the camera Y position to the player y position, I should get the world coordinates for the bullets to aim for, but that wont work for some reason. They just go haywire and go everywhere. I have tried multiple different ways but cant get it. Once the camera reaches the end of the world, everything works correctly, the bullets leave the correct position, and they go to the player. That is why this is so frustrating, because it feels like the solution is right in front of me but I cant figure it out!
Anyways, sorry for this big post, I actually was looking for a point in the right direction, rather than a fix - which is why I posted so much. I really am trying to figure out as much as I can by myself. I am using a piece of code for the heatseeking bullets that I got from here on the forum - because that level of math completely goes over my head and I would have no clue (i did give it a go though : ))
I have included my current .love, you can ignore all the enemies and bullets that are flying everywhere. They wont kill you. The tanks will appear and start shooting after about 5 seconds. I should also warn you that this is my first time programming (just started a couple of months ago) so my coding cleanliness might not be what you expect - however it is indented (if correctly, I dont know).
Again I apologize for the length of this.
Rockford
I know this is an old thread, but seeing as it is about this library I thought it okay : )
I am running into a problem that my inexperienced mind cant figure out.
Here is what I have:
A player that moves with the camera. Can move around freely without affecting what the camera looks at.
The camera moves at a steady rate of 15 * dt upwards.
I have enemies that move independently of the camera - that shoot at the player.
I cant figure out how to have the bullets from the independent enemies, target the player. Either the bullets (from a "tank") appear from the middle of the screen, or if I switch it up, the bullets target an area just above the player (but appear at the tank). The bullets are "heatseekers" so they follow the player around.
I know that I need to account for the fact that the tanks and its bullets are using the coordinates for the whole world, and that the player coordinates are within the fixed viewport of the camera. But I cant seem to figure it out. I have spent just over 4 hours trying to find a solution - but I believe that the solution is very simple - I just cant "see" it yet.
If I add the camera Y position to the player y position, I should get the world coordinates for the bullets to aim for, but that wont work for some reason. They just go haywire and go everywhere. I have tried multiple different ways but cant get it. Once the camera reaches the end of the world, everything works correctly, the bullets leave the correct position, and they go to the player. That is why this is so frustrating, because it feels like the solution is right in front of me but I cant figure it out!
Anyways, sorry for this big post, I actually was looking for a point in the right direction, rather than a fix - which is why I posted so much. I really am trying to figure out as much as I can by myself. I am using a piece of code for the heatseeking bullets that I got from here on the forum - because that level of math completely goes over my head and I would have no clue (i did give it a go though : ))
I have included my current .love, you can ignore all the enemies and bullets that are flying everywhere. They wont kill you. The tanks will appear and start shooting after about 5 seconds. I should also warn you that this is my first time programming (just started a couple of months ago) so my coding cleanliness might not be what you expect - however it is indented (if correctly, I dont know).
Again I apologize for the length of this.
Rockford