My first game – Planet Hunter

Intro

Hi every one!  I made a game called Planet Hunter with lots of help from my father especially for debugging. You can watch a demo of the game in this video below.

https://youtu.be/NEZgoT0e0lU

If you want play this game check out the github repository iniyan2013/planetHunter: a planet hopping developed on python (github.com)

Please share your comments about the game
About the program 
I wrote it in Python language using turtle graphics library. A important thing is if you have mac, Lunix, Unix, Boss, IBM, Debian, and etc. , the sound will not work, and you can only play this game on PC.  Audio will only work on widows. If you ask how this program works this article is the right place. First you should list the imports. Turtle for writing score, Winsound  for scoring sound, it is not fully necessary its your wish. when I was starting to program I didn’t use Winsound in fact I only imported turtle. And os for the shape and image. Time module for delaying.
import turtle
import winsound
import time
import os
Now we will see how to work with the screen we need to use turtle for this. when I was doing this I
did ‘t have any mistakes on this.
screen = turtle.Screen()
screen.setup(600,600)
screen.bgcolor(“black”)
Now I will show you how the planet is changing. You know at first the planet was only mars and can’t change the planets . Here you will also spot the planet names which is displayed. That also had been tricky ,because I didn’t use the for loop properly. The iPlanetCounter decides which planet should go, or come.

Description = [“Mars”,”Jupiter”,”Saturn”,”Uranus”,”Neptune”]
planets = [“mars.gif”,”jupiter.gif”,”saturn.gif”,”uranus.gif”,”neptune.gif”]

#starting index for planet
iPlanetCounter = 0

The following code writes name of first planet, and shows  first planet.

screen.addshape(plim)
PlanetName = turtle.Turtle() #instantiates a Turtle object from the Turtle class.
PlanetName.hideturtle() #hides the turtle
PlanetName.penup() #stops the turtle from drawing a line whenever moving
PlanetName.goto(130,180) #moves the turtle to the top right corner of the screen
PlanetName.color(“blue”)
PlanetName.write(“Planet names: “, align =”left”, font=(“Courier”,15,”bold”))
PlanetName.goto(300,180)
PlanetName.write(Description[iPlanetCounter], align =”left”, font=(“Courier”, 15,”bold”))
The following code adds the score and game player

screen.addshape(“boy.gif”)

#global variables
score = 0
isGameOn = 1

#score turtle
sturtle = turtle.Turtle()
sturtle.hideturtle()
sturtle.penup()
sturtle.goto(-300,180)
sturtle.pendown()
sturtle.color(“blue”)

sturtle.write(“score:”,align =”left”, font=(“Courier”,15,”bold”))
#sturtle = turtle.Turtle()
sturtle.penup()
sturtle.goto(-190,180)
sturtle.pendown()
sturtle.color(“blue”)

sturtle.write(“0″,align =”right”, font=(“Courier”,15,”bold”))
#timer turtle

#player fox turtle
fox = turtle.Turtle() # instantiates a Turtle object from the Turtle class into fox
fox.shape(“boy.gif”) # sets the shape of the turtle to fox.png
fox.resizemode(“auto”)
fox.penup() # stops the turtle from drawing a line whenever moving
fox.speed(0) # sets the turtle’s speed to ‘fastest’
fox.goto(-200,-200)
#planet turtle
planet = turtle.Turtle() # instantiates a Turtle object from the Turtle class into fox

planet.shape(planets[iPlanetCounter]) # sets the shape of the turtle to fox.png
planet.resizemode(“auto”)
planet.penup()

 


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *