Python Forum
My boiler plate for pygame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My boiler plate for pygame
#1
My boiler plate for pygame is a small project.
It contains scene flipping , tick timer builtin to scenes, and has widgets.
Only tested in python 3.6 on Antergos(Arch linux).

Any improvements suggestion are welcome.
Code on github
sample code.
#               *** *** Open a basic Screen with a Scene *** ***

# just import the basics
import pygame
from pyscene import Scene, Screen

# inherit Scene allows the class to interface with Screen
class MyScene(Scene):
    # where all draw commands go
    def blit(self, surface):
        surface.fill((0,0,40))

    # where all event go
    def event(self, event):
        if event.type == pygame.QUIT:
            Screen.close()

if __name__ == '__main__':
    # The Screen will handle pygame.init() and pygame.quit()
    # let create a Screen
    Screen.open('Basic Screen', (800, 600))
    # let add a scene to Screen
    Screen.scenes['MyScene'] = MyScene()
    # let the action begin
    Screen.loop('MyScene', 30) # start scene, frame per seceond
99 percent of computer problems exists between chair and keyboard.
Reply


Messages In This Thread
My boiler plate for pygame - by Windspar - Dec-12-2017, 03:47 PM
RE: My boiler plate for pygame - by Windspar - Dec-14-2017, 04:45 PM
RE: My boiler plate for pygame - by Windspar - Jan-18-2018, 10:27 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020