This repository was archived by the owner on Apr 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Get Started
Modar Nasser edited this page May 10, 2020
·
7 revisions
During this Get Started, we'll create a simple game to understand how to use the framework/engine.
To start, create the following directory and files structure:
NasNasProject
|_ assets
|_ src
game.py
main.py
Where:
-
assets
folder will contain all your resources (png, fft, ogg ...) -
src
folder will contain all your codes
In this Get Started, ns
will refer to the NasNas game framework.
Now, let's go ahead and write some code.
In game.py
, we will start by creating our Game class that inherits from ns.App
which is the main class of the framework.
# src/game.py
import NasNas as ns
class Game(ns.App):
def __init__(self):
# don't forget to call parent's __init__
super().__init__()
Now, in main.py
we need to create an instance of Game and call its run()
method.
# main.py
from src.game import Game
mygame = Game()
mygame.run()
That's it ! Run main.py
, you should see a black 960x540 pixels window running at 60 fps.
It is simple isn't it ?
run()
method is actually defined in ns.App
. All what it does is starting the game loop.
<- Installation | Window and Game loop ->