Skip to content

Latest commit

 

History

History
110 lines (91 loc) · 3.2 KB

File metadata and controls

110 lines (91 loc) · 3.2 KB

Notes for Platformer

Models

  • struct holding a set of keyboard bindings
  • struct holding a “player” object
  • Consists of a Rect, Controls, and current x and y velocity
  • struct containing 4 rgba ints
  • struct containing an SDL_Rect and a color
  • a container for multiple “Rect” structs
  • consists of a pointer to a list of “Rect” structs and its size in ints

Flow

  1. Initialize SDL stuff
  2. (While testing) initialize objects and player
  3. Begin running the game
    1. Check to see if left or right keys are held
    2. Clear the screen
    3. Pop event off the queue and process
    4. Render platforms
    5. Move player
    6. Render player
    7. Check if level is complete
    8. Handle FPS control
    9. Render frame
  4. Handle errors
  5. Close program

Loading Levels

Description

A level can be loaded from a .txt file. The files should be saved in the assets/levels path. The .txt file lines should correspond to the following format:

  1. Background color
  2. Player model
  3. Number of platforms
  4. The remaining lines should be the list of platforms in the level, one platform per line

Annotated example

Here is an example file in table format. In an actual file, each row would only have the values separated by spaces.

Line 1 (Background Color):

rgba
000255

Line 2 (Player. Color and controls are set by defaults):

Rect rect
SDL Rect shape
xy
5050

Line 3 (Number of platforms):

5

Remaining lines (list of Rect):

SDL Rect shapeColor colorint damaging
xywhrgba
00100050255002550
503005050255002551
300205050255002551
400205050255002551
80020050050255002550

Example file

Example file:

0 0 0 255 50 50 5 0 0 1000 255 0 0 255 0 50 300 50 255 0 0 255 1 300 20 50 255 0 0 255 1 400 20 50 255 0 0 255 1 800 200 500 255 0 0 255 0

Tasks

Add camera

Double jump restraint

Death and respawn mechanics

Improve collision

Parse level from file

Load level from file

Refactor get_line

Create level editor

Migrate away from strsep

Add tests

Finish level

Handle level transitions

Add vertical camera

Bugs

Add collision when hitting platform from the bottom