ascii game camera
Console.draw(x,y,image) and
Console.render();
I am trying to create a camera class using this method which has smooth movement, by none of.them.have worked. I want the camera to center on player.x and player.y as well as use VIEW_width and VIEW_height.
Each image is 4x4 characters.
Does anybody have a solution?
Usually you will subtract each pixel from the camera's position before rendering. The idea is to transform vertices from world space to your camera space.
So if you have a picture at location { x, y } and the camera is centered at { a, b }, when you draw the picture it will be drawn at { x - a, y - b }.
If the camera has a width and height, then you need to scale your screen to be that size. I'm not really sure what you're looking for here since it's just a console game though.
Well yeah, characters on-screen are kinda big and so things on the screen will move discretely. I'm not really seeing the problem.
Could you write down the math that you're performing (or code), and then explain what you want it to do instead? Right now what I am hearing is things like "I divide the player coordinates to access blocks", but I don't know what this divide operation is, and I don't know what "access blocks" means, and so I can't really help you yet.
What he's trying to do is to scroll blocks by characters, one at time.
Instead, since he takes player x and maps it to a character by division to block size, he only gets the block the player is in.
Solution: divide character position by block size, keep the original value (which is probably already there) and consider the modulo by block size. This will give you position of character relative to containing char tile.
At this point you have to update your char tile drawing routines to draw only a part of the tile. Maybe using advanced console io you can also draw outside the visible area; should that be the case you wouldn't need to mess with sub-tile drawing. I'm not aware of those possibilities.
Thanks