Alright, so let’s dive a bit deeper into some of the things I did this last week, the video covers the big and mostly non-technical stuff, but there is always more!
One of the smaller things I worked on was modifying the camera and how it keeps focus on the player. The camera code I was using was a the basic code I had running in the framework, but after playing Space Grunts 1 a couple of times, I noticed I did some extra stuff in that code. It limits the camera movement to only move when absolutely needed, and so most of the horizontal movements don’t even trigger a camera move when you are in a single room. The result is a much more relaxed view for the player.
So I copied the changes of that camera code into the new code I had running, and with some extra tweaks we now have an improved camera running, which roughly looks like this:
tx=tmpPlayer.x+8; ty=tmpPlayer.y; int topUp=16; int topDown=16; if (tmpPlayer.myDirection==Globals.UP) topUp=48; else if (tmpPlayer.myDirection==Globals.DOWN) topDown=48; if (tx<cameraTargetX-64) cameraTargetX=tx; else if (tx>cameraTargetX+64) cameraTargetX=tx; if (ty<cameraTargetY-topDown) cameraTargetY=ty; else if (ty>cameraTargetY+topUp) cameraTargetY=ty; xSpeed=((cameraTargetX- (Render.width>>1)) - offsetX) >> 1; ySpeed=((cameraTargetY- (Render.height>>1)) - offsetY) >> 1; // limit camera movement speed if (xSpeed < -2) xSpeed = -2; else if (xSpeed > 2) xSpeed = 2; if (ySpeed < -2) ySpeed = -2; else if (ySpeed > 2) ySpeed = 2; offsetX+=xSpeed; offsetY+=ySpeed;
The offsetX and offsetY translate to the top-left corner of the screen, and all rendering is done using those coordinates.
I’ve also been reworking the mood of the visuals a bit more, I originally planned to have a much brighter game, but with brightness comes the down-side of not being able to play and create variation with lights. So I dimmed down the light surrounding the player and modified the ambient light for the level a bit more. It sets a different tone, and the bright areas still are very “bright” and colorful, but there are now more areas with a darker moody setting.. which I guess is how space looks!?