+
+ +
+

Welcome to Aiplatformer’s documentation!

+
+
+

About

+

Under construction.

+
+
+

Usage

+

Under construction.

+
+
+

Modules

+
+

AssetLoader

+

Responsible for calling Config.py to load the textures and provide +surfaces for the gamescreen to use.

+
+
+AssetLoader.fill_background(bgr_image)
+

Blits the background image onto the screen in a mosaic pattern

+
+
Parameters
+

bgr_image – Background image

+
+
Returns
+

Screen image

+
+
Return type
+

pg.Surface

+
+
+
+ +
+
+AssetLoader.load_asset(path, size_tuple, length_tuple=(1, 1))
+

Returns a list of surfaces with (len = length, size = size_tuple)

+
+
Parameters
+
    +
  • path (str) – Path to asset

  • +
  • size_tuple ((int, int)) – (width, length)

  • +
  • length_tuple ((int, int)) – (width, length), defaults to (1, 1)

  • +
+
+
Returns
+

Transformed list of surface

+
+
Return type
+

[pg.Surface]

+
+
+
+ +
+
+

Character

+

Contains the Character class with defined how each playable character in the game moves.

+
+
+class Character.Character(name='Player 1', character='Ninja frog')
+

The main character sprite in the game

+

Extension of :class: pg.sprite.Sprite.

+
+
Parameters
+
    +
  • name (str, optional) – Indentifier for character, defaults to ‘Player 1’

  • +
  • character (str, optional) – Name of assets for textures, defaults to ‘Ninja frog’

  • +
+
+
+
+
+direction = 'RIGHT'
+

Direction: [‘LEFT’, ‘RIGHT’]

+
+ +
+
+double_jump = True
+

If the character has its double jump

+
+ +
+
+height = 64
+

Amount of pixels

+
+ +
+
+jump()
+

Jump button call

+

Jump if on ground +Double jump

+
+ +
+
+left()
+

Move left button call

+
+ +
+
+level = None
+

Reference to Level currently occupied by character

+
+ +
+
+level_no = 0
+

Index of current level

+
+ +
+
+right()
+

Move right button call

+
+ +
+
+speed_x = 0
+

Speed in axis

+
+ +
+
+speed_y = 0
+

Speed in axis

+
+ +
+
+state = 'IDLE'
+

State: [‘DOUBLE JUMP’, ‘FALL’, ‘HIT’, ‘IDLE’, ‘JUMP’, ‘RUN’, ‘WALL JUMP’]

+
+ +
+
+state_img = 0
+

Index for the current animation image

+
+ +
+
+tick = 1
+

Keeps tracks of animation tick

+
+ +
+
+update()
+

Updates position, movementspeed and animation, called once every frame

+
+ +
+
+width = 64
+

Amount of pixels

+
+ +
+ +
+
+

Character

+

Contains the CharacterBot class with is a Character but controlled by the cpu.

+
+
+class CharacterBot.CharacterBot(name='Bot1', character='Ninja frog')
+

A character controller by the cpu.

+

Extension of :class: pg.sprite.Sprite and :class: Character.

+
+
Parameters
+
    +
  • name (str, optional) – Indentifier for character, defaults to ‘Player 1’

  • +
  • character (str, optional) – Name of assets for textures, defaults to ‘Ninja frog’

  • +
+
+
+
+
+direction = 'RIGHT'
+
+ +
+
+double_jump = True
+
+ +
+
+height = 64
+
+ +
+
+level = None
+
+ +
+
+random_action()
+

Do a random action

+
+ +
+
+speed_x = 0
+
+ +
+
+speed_y = 0
+
+ +
+
+state = 'IDLE'
+
+ +
+
+state_img = 0
+
+ +
+
+tick = 1
+
+ +
+
+width = 64
+
+ +
+ +
+
+

Config

+

Import configurations from this class such as number of bots, fps etc.

+
+
+

Game

+

Runs the main game

+

Handles the main game logic

+

http://programarcadegames.com/python_examples/show_file.php?file=platform_scroller.py

+
+
+Game.game_loop()
+

Main loop for the game engine

+
+ +
+
+Game.main()
+

Init pg and run game loop

+
+ +
+
+

Level

+

Contains the level basic class, Levels will inherit from this class to make a level. +Also contains the Platform class which specifies solid surfaces in the level.

+
+
+class Level.Level(player, lvl_type='Blue', ter_type='Wood')
+

Default level

+
+
Parameters
+
    +
  • player (Character) – Main character

  • +
  • lvl_type (str, optional) – One of: [‘Blue’, ‘Brown’, ‘Gray’, ‘Green’, ‘Pink’, ‘Purple’, ‘Yellow’], defaults to ‘blue’

  • +
  • ter_type (str, optional) – One of : [‘Gray_Stone’, ‘Green_Dirt’, ‘Wood’, ‘Yellow_Dirt’, ‘Bricks’, ‘Leafs’, ‘Pink_Dirt’], defaults to ‘Wood’

  • +
+
+
+
+
+draw(screen)
+

Draw content on screen

+
+
Parameters
+

screen – The game screen

+
+
Type
+

screen: pg.Surface

+
+
+
+ +
+
+level_limit = -1000
+

Level end x coordinates

+
+ +
+
+shift_world(speed_x)
+

Scroll world

+
+
Parameters
+

screen – The delta in x

+
+
Type
+

screen: float

+
+
+
+ +
+
+tick = 0
+

Keeps track of all animation updates in level

+
+ +
+
+update()
+

Update everything

+
+ +
+
+world_shift = 0
+

How much the world is shifted in x

+
+ +
+ +
+
+class Level.Platform(width, height, x, y, ter_type='Wood')
+

Platform the player can jump on

+
+
Parameters
+
    +
  • width (int) – Pixel width

  • +
  • height (int) – Pixel Height

  • +
  • x (int) – X coordinate of upper left corner

  • +
  • y (int) – Y coordinate of upper left corner

  • +
  • ter_type (str, optional) – Terrain type of platform. One of: [‘Gray_Stone’, ‘Green_Dirt’, ‘Wood’, ‘Yellow_Dirt’, ‘Bricks’, ‘Leafs’, ‘Pink_Dirt’]

  • +
+
+
+
+ +
+
+
+
+
+

Indices and tables

+ +
+ + +
+ +