I am making a game(no duh) using slick2d. Right now, I am trying to figure out how to make a view. I don’t know how others do it, but I started thinking that I could give each entity a normal x and y, and a drawing x and y. I don’t really wan’t to do that, because it sounds like a lot of writing and I am kind of lazy. Any help would be appreciated!
If you would care to elaborate on what you want help with, I’d gladly help you. But ‘setting up a view’ is a tad to vague to get a decent answer.
If you’re trying to use a camera, you can put this at the beginning of your games render function:
That will make the camera follow your player (But he will be at the top right corner of the camera. You might want to center it.)
Actually you may want to do gr.translate(-player.x,-player.y) since translating positive values moves the map to the right.
Then change this to:
gr.translate(-(player.x-player.width/2) + screenWidth/2, -(player.y-player.height/2) + screenHeight/2);
Thank you! But I already knew how to do that. I just didn’t know how to make the views. I used hard coded values instead of doing that, which would be a better way. Thank you two for you help.
Maybe the OP means a way to avoid manipulating x and y manually.
I think that I am bad at posting understandable posts. I didn’t know about the translate command, but I knew how to center it. I am really bad at making posts on forums.
Don’t be too hard on yourself. I’m pretty bad at posting understandable content too. That’s dog the fork for ten hababa indigo. If ael a;m efk slse, foin. adelfj ielomf awof, oq? ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++…+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
Is that BrainFuck code? I ran that and it said “Hello World!” hehehehehe ;D
Lol, you got it! Maybe I’m getting better at making understandable posts!
I don’t get this part though…
you have to code a “camera”