Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Tile Engine Camera Problem

This topic is 5785 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone, i am creating a tile engine, its going good. Anyways, i have a major problemThe problem is this. I have the tilemap drawn which works fine. I have the camera collision detection working(so it doesnt go off the screenAnd i have player collisionw ith the edges of the map, simple stuff. Anyways, heres the problem. When my player moves, the camera follows him, this is whats supposed to happen,hehe. The problem is when the camera moves witht he player, the player moves too many times. Like lets say my character is set to move 32 pixels(the size of a tile), when he moves to the right, and the camera moves with him,he moves 2 tiles instead. Whent his happens, the player moves too fast for the camera to stay with him, so he then moves out of camera view. Ill now show some camera code, because i think i use my camera a LOT differently that most pl if (KEYDOWN(VK_RIGHT) && (Char.xMove == 0) && (Char.yMove == 0)) { if(Char.CharacterX>=50*32-800) { Char.CharacterX=50*32-832; } else Char.CharacterX=Char.CharacterX + 32; Char.xMove = 1; Char.xTile++; } Thats the code for the player to move. switch(TileMap) { case 0:Tile.Draw(1,0,TileX*TileSize-Cam.xCamera,TileY*TileSize-Cam.yCamera); break; } this is the code used to draw the tiles, and this is where i add my camera values. This code sets the camera to follow the player. BTW this isnt my code, its from the 10 lesson tile engine rpg tutorial(this center camera party anyways Cam.xCamera = (Char.xTile<<5) + Char.CharacterX - 384; Cam.yCamera = (Char.yTile<<5) + Char.CharacterY - 284; I was also wondering what the << means math wise /////Draw Player////////// Tile.Draw(7,0,Char.CharacterX,Char.CharacterY); ///////////////////////// The thing i dont understand is why the camera would affect the player movement when the player is NOT part of the tile map, he is a separate entity. Thx alot for any input, i really want to get this to work. ALSO, my finally question(big list hereis how do i make it so when the character moves, he doesnt instantly appear at that tile. I want him to move to that tile, and the camera to slowly move with him, not just instantly appear. Thx alot for any input, answer as many questions as ya want

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!