hyperkaos/README.md

202 lines
6.4 KiB
Markdown
Raw Normal View History

2020-05-03 05:36:33 +00:00
# HyperKaos engine
2019-11-15 06:26:49 +00:00
2020-05-03 05:36:33 +00:00
## Engine.c
2019-11-15 06:26:49 +00:00
2020-05-03 05:36:33 +00:00
### loadImage(char* filename)
2019-11-15 06:26:49 +00:00
returns an SDL_Surface* of the image file at given file path
2020-05-03 05:36:33 +00:00
### applySurface(int x, int y, SDL_Surface* src, SDL_Surface dest, SDL_Rect* clip)
2019-11-15 06:26:49 +00:00
wrapper for SDL_BlitSurface, drawing src onto dest with origin (x,y) and clipped according to clip
2020-05-03 05:36:33 +00:00
### getPixel(SDL_Surface* surface, int x, int y)
2019-11-15 06:26:49 +00:00
get color value of a pixel on an SDL_Surface as a Uint32
2020-05-03 05:36:33 +00:00
### scaleScreen()
2019-11-15 06:26:49 +00:00
scales the game widow from native resolution of 320x180 to integer multiple according to config.h
2020-05-03 05:36:33 +00:00
### loadBGM(char* filename)
2019-11-15 06:26:49 +00:00
sets hasMusic for this map chunk to True and returns the file as a Mix_Music*
2020-05-03 05:36:33 +00:00
### loadSFX(char* filename)
2019-11-15 06:26:49 +00:00
returns a Mix_Chunk* of the wav file at given path
2020-05-03 05:36:33 +00:00
### renderBackground()
2019-11-15 06:26:49 +00:00
paints the current room's background image and increment its animation
2020-05-03 05:36:33 +00:00
### renderForeground()
2019-11-15 06:26:49 +00:00
paints the current room's fg objects and people, and the player
2020-05-03 05:36:33 +00:00
### renderHUD()
2019-11-15 06:26:49 +00:00
paints the spell selection HUD
2020-05-03 05:36:33 +00:00
### interact()
2019-11-15 06:26:49 +00:00
grabs keyboard input in the main loop and modifies the game state
2020-05-03 05:36:33 +00:00
### kListen()
2019-11-15 06:26:49 +00:00
checks if spell has been cast; if so, looks up the spell in the spellbook and does a synergy; then unsets the spell lookup;
then checks if any eventTriggers have been activated; due to the implementation of hyperKaos, if more than one are activated at the same time, the one later in the array is run
2020-05-03 05:36:33 +00:00
### init(int argc, char** args)
2019-11-15 06:26:49 +00:00
initializes SDL subssytems, creates game window, loads UI data and hero data, allocates memory for mapData and mapBuffer, dialogueData, kaosData, theatre (scene data), and builds the spellbook
2020-05-03 05:36:33 +00:00
### writeSpellbook()
2019-11-15 06:26:49 +00:00
builds some hyperKaos* and stores them in spellBook
2020-05-03 05:36:33 +00:00
### burnSpellbook()
2019-11-15 06:26:49 +00:00
deallocates spellbook Memory
2020-05-03 05:36:33 +00:00
### toggleFullscreen()
2019-11-15 06:26:49 +00:00
reinvents the wheel with SDL_SetVideoMode
2020-05-03 05:36:33 +00:00
### timeDilation()
2019-11-15 06:26:49 +00:00
waits with SDL_Delay to keep a constant framerate
2020-05-03 05:36:33 +00:00
### frameAdvance()
2019-11-15 06:26:49 +00:00
scales the internal screen to the game window size, updates the game window, and waits to start the main loop over
2020-05-03 05:36:33 +00:00
### cleanup()
2019-11-15 06:26:49 +00:00
enters windowed mode, cleans up all the memory, closes SDL subsystems
2020-05-03 05:36:33 +00:00
### intro()
2019-11-15 06:26:49 +00:00
builds a couple Scene*s for the intro sequence, plays them, and cleans up the memory.
2020-05-03 05:36:33 +00:00
### mainmenu()
2019-11-15 06:26:49 +00:00
listens for keyboard input and navigates the main menu. reads save file if continued game, otherwise sets game data to the beginning of the game. or quit. takes control of the main game loop
2020-05-03 05:36:33 +00:00
### pausemenu()
2019-11-15 06:26:49 +00:00
listens for keyboard input and saves, quits, or continues playing; takes control of the main game loop
2020-05-03 05:36:33 +00:00
## WorldData.c
2019-11-15 06:26:49 +00:00
2020-05-03 05:36:33 +00:00
### bufferData(int chunk)
2019-11-15 06:26:49 +00:00
sets hasMusic to flase, paints loading message on screen, builds world chunk; if there is an error building the world, quit the game
2020-05-03 05:36:33 +00:00
### hashCmd(char* x)
2019-11-15 06:26:49 +00:00
return an 8bit hash on a string for interpreting the worldBuilder script (this means there are max 256 commands for map generation, excluding "<" which functions as a closing bracket for "if" and "ifNot" directives)
2020-05-03 05:36:33 +00:00
### worldBuilder(int chunk)
2019-11-15 06:26:49 +00:00
allocates memory, opens map data file for current chunk; reads line by line, hashing the first word of the line, then switching on that to execute an action; bubbles up failure (malformed lines) by returning nonzero; returns zero if the whole file is read and processed
2020-05-03 05:36:33 +00:00
### buildBGM(char* props)
2019-11-15 06:26:49 +00:00
parses the args of loadBGM worldBuilder command and passes them to loadBGM(); return nonzero if malformed
2020-05-03 05:36:33 +00:00
### buildSFX(char* props)
2019-11-15 06:26:49 +00:00
parses the args of loadFX worldBuilder command and passes them to loadSFX(); return nonzero if malformed
2020-05-03 05:36:33 +00:00
### buildRoom(char* props)
2019-11-15 06:26:49 +00:00
parses the args of mkRoom worldBuilder command to build a room and place it in mapBuffer; return nonzero if malformed
2020-05-03 05:36:33 +00:00
### buildTextBox(char* props)
2019-11-15 06:26:49 +00:00
parses the args of mkTextBox worldBuilder command to build an empty textBox and place it in dialogueData; return nonzero if malformed
2020-05-03 05:36:33 +00:00
### modTextBox(char* props)
2019-11-15 06:26:49 +00:00
parses the args of addText worldBuilder command to add text to the indicated textBox in dialogueData; return nonzero if malformed
2020-05-03 05:36:33 +00:00
### buildSynergy(char* props)
2019-11-15 06:26:49 +00:00
parses the args of addSigil worldBuilder command to pass to addSigil(); return nonzero if malformed
2020-05-03 05:36:33 +00:00
### buildKaos(char* props)
2019-11-15 06:26:49 +00:00
parses the args of mkKaos worldBuilder command, switches on the class to figure out which constructor to pass the subsequent args to returns nonzero if malformed
2020-05-03 05:36:33 +00:00
### buildObstruction(char* props)
2019-11-15 06:26:49 +00:00
parses the args of addObstruction worldBuilder command, passes them to addObstacle(); returns nonzero if malformed
2020-05-03 05:36:33 +00:00
### buildFGImage(char* props)
2019-11-15 06:26:49 +00:00
parses the args of addImg worldBuilder command and passes them to addFGObj(); returns nonzero if malformed
2020-05-03 05:36:33 +00:00
### buildWarp(char* props)
2019-11-15 06:26:49 +00:00
parses the args of addWrap worldBuilder command and passes them to addWarp(); returns nonzer o if malformed
2020-05-03 05:36:33 +00:00
### buildHyper(char* props)
2019-11-15 06:26:49 +00:00
parses the args of addTrigger worldBuilder command and passes them to addTrigger(); returns nonzero if malformed
2020-05-03 05:36:33 +00:00
### chainKaos(char* props)
2019-11-15 06:26:49 +00:00
parses the args of the chainKaos worldBuilder command and passes them to addKaos(); returns nonzero if malformed
2020-05-03 05:36:33 +00:00
### buildPerson(char* props)
2019-11-15 06:26:49 +00:00
parses the args of the addPerson worldBuilder command and passes them to addPerson(); returns nonzero if malformed
2020-05-03 05:36:33 +00:00
### countMapThings(int* count, int chunk)
2019-11-15 06:26:49 +00:00
writes counts of global memory objects in this chunk to count based on mapdata file; this means the map data must be read again to count global objects before deletion!
2020-05-03 05:36:33 +00:00
### dataPurge(int* counts)
2019-11-15 06:26:49 +00:00
takes counts produced by countMap to free map chunk data
2020-05-03 05:36:33 +00:00
### unloadData(int chunk)
2019-11-15 06:26:49 +00:00
allocates count buffer for global map objects, counts the objects with countMapThings(), and passes it to dataPurge()
2020-05-03 05:36:33 +00:00
### pushBufferData()
2019-11-15 06:26:49 +00:00
moves mapBuffer to mapData and allocates new mapBuffer; if music was loaded in the new map chunk, play the first track
2020-05-03 05:36:33 +00:00
### pager()
2019-11-15 06:26:49 +00:00
2019-11-15 22:11:01 +00:00
if the player is warping to a new map chunk, halt the music (if any), unload the current map chunk before pushing mapBuffer to mapData
2020-05-03 05:36:33 +00:00
## TextBox.c
2019-11-15 22:11:01 +00:00
2020-05-03 05:36:33 +00:00
### newTextBox()
2019-11-15 22:11:01 +00:00
returns a pointer to an empty TextBox
2020-05-03 05:36:33 +00:00
### newGTextBox(SDL_Surface* image)
2019-11-15 22:11:01 +00:00
returns a pointer to an empty TextBox, with portarit image
2020-05-03 05:36:33 +00:00
### deleteTextBox(TextBox* target)
2019-11-15 22:11:01 +00:00
deallocates memory for target
2020-05-03 05:36:33 +00:00
### addText(TextBox* self, char* text)
2019-11-15 22:11:01 +00:00
adds the string of text as a line in the TextBox pointed to by self
2020-05-03 05:36:33 +00:00
### textBoxInput(TextBox* self, int* textIsRelevent)
2019-11-15 22:11:01 +00:00
increments TextBox cursor, handles keyboard input while TextBox is onscreen
2020-05-03 05:36:33 +00:00
### displayTextBox(TextBox* self)
2019-11-15 22:11:01 +00:00
takes control of the main loop and draws the room, foreground, and the TextBox over it all, and passes input to textBoxInput()