ascii game camera

Started by
5 comments, last by Waterlimon 8 years, 12 months ago
I am creating a text based game in the console using a special windows only technique and my own image class system, that can easily be drawn with
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?
Advertisement

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.

What I am wanting is a scrolling camera, using the double buffer system, I created my own image class and loading system, and what I need is for the camera to follow the player, meaning, showing any part that the player can see and disregard what the player isn't supposed too, as this is a tile map. The problem I'm.having with the x-a system, is transforming player coordinates to.block coordinates, as a player moves by pixel, and a block is 4 pixels, (when I say pixels I mean single chars) , and when I devide the player coordinates to access blocks, the camera only shows a new block every 4 steps.

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.

Previously "Krohm"

That was exactly what I was looking for, and there is not a system, to my knollege, that allows for off screen drawing on the console, so I'll use this method
Thanks
You can first draw to your own buffer that is bigger than the screen, and then draw the visible section to the actual output. This way you dont need to have if checks for every tile or character to check if its in screen (could be a performance problem). A small 1-tile wide buffer region around the screensize buffer basically. (any remains of half visible tiles go there)

o3o

This topic is closed to new replies.

Advertisement