Monday 29 May 2017

Game design with blender and python #1

I have made a basic game on scratch then I used python to make another basic game.Now I am using blender to create a easy and fun game. In blender I can move my character around and now I am working on creating the game. In blender I have set up the w,s,a and d keys to move around and I'm also setting up the space key to jump.


Blender is a game engine which uses logic to create a game. The first thing I did was setting up the wsad and space key using the controllers actuators and sensors. After that I added in gravity and a platform I also went and added coins so there is an objective in the game. I set up a score board at the top of the screen to show many coins you have collected and i also set up platform you have to jump to to get the coins.

My next step in blender is to make my start and Finnish screens. i also want to create more than one stage in the game to play.


Wednesday 10 May 2017

Problem Solving with Python #Post 1

So far in computing we have learnt how to use scratch and I have been learning how to use python for two weeks.
I have used three programs when I was making my code: Tinker, Python IDLE and code combat.
I understand the Python is a language and I know if something goes wrong I can try my hardest to find out what is not working and solve the problem. I understand that Python is very precis about it's instructions so I have to work very carefully when setting up the script so there is no mistakes.  
I have learnt how to make a python IDLE template,set up game loops,sprites and how to set up the window.

Here is my example of how to set up the window the line with hashtags are telling you what s happening they have no effect with the script:    
#start pygame
import pygame
import random

#2. setting up window (FPS=Frames per second)
WIDTH = 360
HEIGHT = 480
FPS = 30

#intalize pygame and create window
pygame.init()

#To make sounds
pygame.mixer.init()

#Screen display
screen = pygame.display.set_mode((WIDTH, HEIGHT))

#Name and the clock (the clock is to keep the game running at the right speed)
pygame.display.set_caption("Joel's Game")
clock = pygame.time.Clock()


Here is my example on how set up the colors

#3 define a few useful colors (used to color in the background and sprites)

WHITE=(255, 255, 255)
BLACK=(0, 0, 0)
RED=(255, 0, 0)
GREEN=(0, 255, 0)
BLUE=(0, 0, 255)



Here is my example on how set up sprites for the player

#Creating the sprite for the player (setting up the player)

class Player(pygame.sprite.Sprite):
          def __init__(self):
            pygame.sprite.Sprite.__init__(self)
            self.image = pygame.Surface((50, 50))
            self.image.fill(GREEN)
            self.rect = self.image.get_rect()
            self.rect.center = (WIDTH / 2, HEIGHT / 2)

            def update(self):
                self.rect.x += 5
                if self.rect.left > WIDTH:
                    self.rect.right = 0

# Creating Sprites

all_sprites = pygame.sprite.Group()
player = Player()
all_sprites.add(player)

And last of all my example on how to set up a game loop

#game loop
running = True
while running:
    #keeps game loop running at right speed
    clock.tick(FPS)
    # processes input (events)
    for event in pygame.event.get():
        #check for closing window
        if event.type == pygame.QUIT:
            running = False
           
    # Update
    all_sprites.update()

    #draw and render the screen
    screen.fill(BLACK)
    all_sprites.draw(screen)

    #always do after the Draw and render screen 
    pygame.display.flip()

# So you can quit the game
pygame.quit()



All of that is what I made for the first time I used Python IDLE.
I managed to make this game with few mistakes that I fixed very quickly so when I finished the session the game was working.I managed to make this script with miss Chowfins help in class