Wednesday, January 27, 2016

January Game - Nearing Completion

The month is drawing to a close and so the game I've been working on is nearing its own completion.

I've done a few things in the past day or two, namely updating the graphics and trying (yet failing) to implement sound.

I also made the game full screen.
When making a game full screen in Game Maker, there are two things you can do: Increase the size of the window but keep the sprites the same size, which both requires more coding and, in my opinion, looks worse. Or, you can do it the easy way, which scales the sprites with the size of the window.

I did this by making an invisible object, one that doesn't have a set sprite, and placing it in the room. In the Create event, I put this simple line of code in it: window_set_fullscreen(true)

This is a simple boolean (true or false) function that checks to see if you're setting the window size to fullscreen.

Now, if you were to throw that code into that object, place it in the room and boot it up, you might notice something wrong. Something... fuzzy.
So, you may have noticed all the blurryness of the image and the white artifacting around the bandit. For some reason, Game Maker has a setting that is toggled by default that does this whenever you scale a sprite in-game. This can be easily fixed.


First, go to the Resources tab, and on the drop down menu, select "Change Global Game Settings". On the window that pops up, select the "Windows" tab on the top and then the "Graphics" tab on the side. There's a checkbox for "Interpolate colors between pixels".

Do yourself a favor and uncheck this box. From now on, any in-game scaling will be pixel perfect.

As for the black bars around the sides image at the top of this article, this method of making the game fullscreen doesn't alter the paramaters you set for the view (to learn more about views, check out Tom Francis' tutorials on Game Maker. That link will take you to the specific video on views, also he discusses the other way of making games fullscreen). So, if the view you have for the game set to a different ratio than your own monitor, you'll get those very attractive black bars in order to make up for it.
As you'll see in this photo, I've also added clouds. Or, more specifically, their shadows. This doesn't exactly have much bearing on gameplay, but I thought it would be important to have some sort of slow moving ambiance. Some constant movement to keep it from being boring.

I simply made a sprite that had three frames, put it into an object, and set the image_speed to zero, so that the clouds wouldn't be constantly changing shape.

Here's the code that I've used in the Create event (any comments between /*   */ are not part of the code):

y = random(200) /* this places the instance of the cloud somewhere randomly on the y-axis between 0, the top of the screen, and 200, which is lower on the screen */
image_speed = 0 /* this stops the sprite from looping through its frames */
image_index = random(5) /* this sets each instance of the cloud to a random frame. I chose five because it was more than the number of frames I made. */
image_xscale = 0.2 + random(1.2) /* this will change the width of each instance of the cloud between a fifth of its size to two fifths bigger */
image_yscale = image_xscale /* this scales the height of the cloud equally with the width */

Once the clouds are in the game, they need to move. Originally I had them moving in both directions; left to right and right to left. But this made things difficult and also didn't make any sense. Clouds move in the same direction. 

Now I have them moving right to left. In order to save on memory, once they leave the room, the sprites are destroyed, but not before creating another one to replace it.

Here's the code that I used in the Step event:

x -= 0.7 /* this makes the cloud move from right to left */

if x <= 0 { /* this checks to see if the cloud has left the room. 0 is the leftmost border of any room. */
instance_create(room_width+1000,random(200),oDust) /* before I destroy this instance, I create a new one, outside of the room. The parameters in the parenthesis are x, y, and the name of the object you are creating. Room_width+1000 places the cloud 1000 pixels to the right of the room, random(200) has the same function it does in the Create event, and oDust is what I named my cloud object */
instance_destroy() /* This destroys the instance of the cloud that has exited the room */
} /* always make sure to close your "if statements". */

I've also been thinking about making the game more about an inevitable death rather than a simple win or lose situation.

It's something I'll tinker with, but I'm planning on making it so that the game doesn't end when the bandit shoots their gun and misses the "coward". The clock will keep going and going until the bandit kills him. I'll possibly increase the speed of the timer each turn, as well.

Finally, I've learned how to create a title that fades into the game. Before now, I've only worked with a single room. But as it turns out it's a very simple concept.
When the game starts, you are greeted by this, telling you my information; my twitter and both of my blogs. After a few seconds, it fades out and the game begins.

Here's the code for the object that I created with that text as the sprite:

Create Event
x = room_width/2
y = room_height/2
RoomTimer = 0 /* this is a variable I created. */

Step Event
RoomTimer += 1 /* as soon as the information appears on screen, this timer begins */

if RoomTimer >= 100 { /* It's good practice to use > or < before the = on most if statements. This way, it'll still work if you go past your goal */
image_alpha -= 0.1 /* begin to fade */
}

if image_alpha <= 0 and RoomTimer >= 150{
room_goto(1) /* once the object is completely transparent, it moves to the next room */
}

if keyboard_check(vk_enter) {
room_goto(1) /* or, alternatively, if you press enter, it'll just skip to the next room */
}

Importantly, Game Maker will always start with the room that is highest on the room list, like this:
Sorry, but the tumbleweed isn't making it into the final cut of the game.
Room0 will always be the room that Game Maker starts with, not because it's a lower number, but because it's on top.

Also, Game Maker numbers always start with 0. Room0, even if it was named room15, would be classified as the zeroth room. The first image on roll of sprite frames would be number zero and the second would be number one.

That's all I have for now, thanks for reading!

No comments:

Post a Comment