60 seconds: chase first version look 11 december

 

Hi guys this is Babaman studios!

The video above is run of our future's game first version. As you can see, you control the green block using WSAD keys and have to touch the grey block to score a point and you have 60 seconds. That is pretty much it and that's why it is the first version.

We are going new things such as highscores, power-ups and enemies to - you know - spice up the game.

Now if you want to learn how this program works read more to learn more! just do not worry I wrote it in english. 

  These are the main functions and mechanics: 

Player movement:

The coding instruction for movement and sensing is really strange in my opinion here is the part of the code or the module which is responsible for giving motion:

The "def controls()" declares the chunk of code below as "controls()". So when the time comes I can just type "controls()" to give the player motion.

 Then the 'if' parts are actually sensing commands meaning they check if something is true like in this case press of a key. 

Now each key is labeled as keyboard_key[here key name]. Now the part underlined is the name of the key so for key a it will be 'pygame.K-a'. After that comes the movement commands, which are in between if statements with an indentation.

 Now to move the damn player the format looks like this: playname.move_ip(change in x, change in y). Here the playername is obj. All change in x or y values are set as 3 to keep the cube fast.

Target position assignment:


  So this part of the code just randomizes he position of the target block after it's touched.

Now here is a detailed breakdown of the module:

  • 'if obj.colliderect(target):' this part checks if obj (player) is touching (calculated using colliderect()) the target.
  • 'global score' this is used to access the variable score.
  • Now the forth and fifth line just randomizes the position of the target. The forth line randomizes value of x by assigning a random value between 0 and 600 and line 5 randomizes value of y between 0 and 500.  So 'target.x' literally means value of x of target then 'random.randint()' the command to pick a random number between 2 numbers which are place in in it's brackets. Same goes with y.
  • 'score +=1' increases value of score by 1 so it is in simple terms score = score +1.  

 so you get a result like this:


 

There are other big mechanisms too like game-over screen and pygame main loop, I will cover then in separate blogs.

 

So guys stay tuned for version 2 and to understand other mechanisms of the program. 

Comments

Popular Posts