pygame questions

pygame questions

Postby jonin » Thu Jul 03, 2014 8:57 pm

Hi guys,

im interested in python and more so pygame
i want to make simple 2d games while learning python at the same time
i got a book called python for absolute beginners, and find it interesting but annoying at the same time
i guess my problem is i want to fly before i can walk
i really want to start seeing results using pygame
i used code academy for a while, and understood a lot but cant see how to apply what im learning to make a game
a friend of mine who is a c# programmer said "just jump in, learn as you go"
should i stick to the book and code academy, or should i just start writing a game and see where it takes me?
i have made a title screen using photoshop but have no idea how to apply it as a background to a menu
i have looked up title screen tutorials but they are there own style and dont explain how to use a png, or jpg to utilise as
a background for a custom title screen

any info,help advice greatly appreciated...
jon1n
jonin
 
Posts: 8
Joined: Wed Jun 11, 2014 9:29 pm

Re: pygame questions

Postby metulburr » Fri Jul 04, 2014 3:45 am

I could not stress enough to learn the basics before starting programming games. Make sure to understand classes, data structures, File I/O. There is nothing wrong with learning on the fly as you go, but set aside some time to learn those without the game part. Once you have dabbled into those, then yeah just jump into it.

You cannot make a gif animated, and display that. You need to animate that yourself in pygame by flipping through each image. It can get more complicated depending on how much you want going on in your background.

If its just a still image, then you treat it as that. You would display an image for a menu like any other image in pygame. Then you would draw your buttons or other UI on top of that.

Here is an example:
Code: Select all
import pygame as pg
pg.init()
screensize = (800,600)
screen = pg.display.set_mode(screensize)
bg = pg.image.load('menu_bg.png').convert()
done = False
while not done:
    for event in pg.event.get():
        if event.type == pg.QUIT:
            done = True
    screen.blit(bg, (0,0))
    pg.display.update()


In this example i just create a window with display.set_mode(). I load the image with image.load(). I create a game loop with the while statement. I check for events, draw the background, and update the display.

example image:
https://github.com/metulburr/WarCraft-2 ... enu_bg.png
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1448
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: pygame questions

Postby jonin » Fri Jul 04, 2014 10:22 pm

thanks for that...i have decided to do both...study theory during the week and work on a project on weekends...
cant wait
jonin
 
Posts: 8
Joined: Wed Jun 11, 2014 9:29 pm


Return to Game Development

Who is online

Users browsing this forum: No registered users and 2 guests