7 Days to a Game ~ Day 6! Scores, Time, and Lives! It’s a game!

//7 Days to a Game ~ Day 6! Scores, Time, and Lives! It’s a game!

7 Days to a Game ~ Day 6! Scores, Time, and Lives! It’s a game!

  Today was a pretty productive day! I played Borderlands 2 for 2 hours, Vacuumed the living room, cleaned the kitchen counters, and did the laundry. Oh did I mention I also made a ton of great progress on the Slap Happy game?

  progress

  Onward to what was accomplished today! Good lord I don’t even remember what happened yesterday. Lets just act like a ton of things happened. Since it had to do with snowballs lets talk about a few things I did with them today and something you should know about debug messages.

  Happy now launches his snowballs both automatically and on click! I did this because I felt that it wasn’t exciting enough without the extra automated action. How did we accomplish this? Well we added another alarm to happy, this one counts down 30 steps (which you remember is equal to 1 second). Once the alarm sounds the following code is run:

image

  Pretty simple stuff! We initialize the variable happythrow in line 1. Then in order for the variable to do anything but crash us we give it a value. In this case I’ve given it the value or round(random(1.1)), you might be saying to yourself “Why 1.1?” The random function in GML does between 0 and beneath whatever number you put. I want the value of 0 or 1 so I put 1.1 and have it round. You’ll note that this means it is slightly more likely to be 1 than it is to be 0. Happy favors one arm over the other and that’s perfectly fine. I’ll invert the two creation scripts tomorrow so that he favors his right arm more (seeing as he’s right handed).

  The instance creation work you saw yesterday and it shouldn’t surprise you at all. It’s dynamic and changes location depending on the location and size of Happy.

  Goal for tomorrow on this script? I want it to throw the first one at 1 second and then throw the next one 5% faster than that and then 5% faster again and so on. This provides a fast paced experience for the user and challenges them to get in as many happy slaps as they can!

  happyslap

  Next task for the day for me was fixing the problem with Happy getting stuck permanently in a corner! This is no fun for anyone! I couldn’t find any functions built into GML that would do it for me. So naturally I sat back, put on my sunglasses, buckled in, sipped my lemon water, and then took my sunglasses off because I couldn’t see a damn thing. After that I started thinking about how I’d fix it!

  Thirty seconds later and…

Eureka!

  If he’s stuck in the same location then naturally his x and y coordinates would be in the same place in two different seconds! Presumably with him always moving (and moving fairly fast) this should not be the case while he’s in motion! (It turned out that it was possible and I toned the fix down to every 3 seconds).

  image

  What’s all that green nonsense? Oh crap! Did I actually put comments in my code?

Run.

Run for your life!

Something is very wrong here!

 

  Are you gone? No? Alright well I guess we’ll talk about it then. So the first line is setting id.wherewasi (a variable I’ve initialized in a creation event elsewhere) to a # equal to the values of Happy’s current X location and his current Y location. I did this because if you put it at simply his x position he will set it off anything he’s walking vertically without any additional x changes. If you set it to only his Y location it will trigger anytime he’s walking horizontally without any additional y changes.

  Makes sense right?

  So anyways. If the game checks there wherewasi variable and notices that he is in the same place it’ll teleport Happy’s ass (and the rest of him) to a random location on the map. It is possible for it to teleport him into a wall but that’s incredibly unlikely and I’ve yet to have it happen. I may put in a fix for that in the future. Additionally it resets the variable by setting it to 0.

  If Happy’s current location does not equal the location he was in the last time the game checked it will simply change the variable to his new location and end the script. Lets see if I can word this all in a shorter chunk.

  Is happy in the same place he was last time?

  If yes then teleport him to a new location.

  If no then go about your business and check back in 3 seconds.

  Next we’ll look at the scoreboard!

  image

  Uh…oh…ok. Well that’s less than exciting? What’s it look like in game?

image

  Alright! Still ugly as dirt but this is more informative! So how did you get those little ? mark thingies to like… be stuff?

  That’s a great question person that doesn’t exist. Lets go over that right now! (I’m using a shit ton of exclamation points.)

  We’ll use time because it’s the most complicated (which is not saying much) and I’m getting a wee bit tired.

  image

  We have 3 events for this object. You’ve got the Create event which you know, the Step event which you know, and the Draw event which is totally new! For Create we have a script running…just what is in that thing?

image

  We are initializing a variable which we’ve named gametime because that’s exactly what it will be. Don’t forget to give it a value or you will piss off Game Maker and any other coding language you are playing with! The defaulting to a value of 0 is incredibly uncommon I’m told.

  I’ve also made the variable global because it will be um…well…global? Yeah.
 image

  Next we’ve got a step event and it is running a…well shit. Yeah that looks like another script. What’s in there?

image
  Ah alright. Not too complicated. The game checks to see if the player still has any lives and if they don’t it increases the variable by .1. The += means that it takes the value and increases it by one. You can just as easily do –= as well which is the reverse.

  We’ve not reached the point where the player can actually see the text yet. This is what Draw is for!

image

  And the pattern of using nothing but code continues! It turns out that I’m using my own code more and more but I can’t promise you that its actually the best method. I’m just a stubborn dude who needs immediate satisfaction. If there is any confusion for me with the buttons in the game I just make my own code to get the project done quicker. Feels a little better too.

image

  I am certain I could run both of these draw scripts in a single draw but I was getting a ton of errors earlier and decided to just do this for now to finish my work. As mentioned before KR Dev teams get paid by the line so I’m maximizing profits right now. Optimization is for suckers! (Also good developers.)

  What this does is draw the words “Time: “ at the location of the second purple ? you saw on the image up a bit. It then writes the current gametime roughly 50 pixels right of that. Simple and elegant-ish!

  We’ve also got draw commands for Lives and Score which are both taken care of natively by the GML. I might go over those tomorrow. But for now why don’t you try the newest build (below) and take a screenshot of your best score! The highest score with the lowest time is currently the measure of the best player! Good luck!

  You can find the latest build of Slap Happy Here! It has an icon now! A very small and ugly one but I’ll do something else later (maybe). Note: It’s difficult to die at the moment. I’ll fix this tomorrow.

[ Table of Contents]

Day 5 – 7 Days to a Game ~ Day 5! This game has (snow)balls!

Day 4 – 7 Days to a Game ~ Day 4! Testing / Bugs / Variables

Day 3 – 7 Days to a Game ~ Day 3! Development and Testing!

Day 2 – 7 Days to a Game ~ Day 2! Art Assets.

Day 1 – Preparations

By | 2013-07-13T23:00:06+00:00 July 13th, 2013|Journal|1 Comment