Operation Null Mind 0.4.1
A 2D roguelike top down shooter game made with SDL2
 
Loading...
Searching...
No Matches
app.h File Reference

This file contains the definition of the AppData struct, and the 6 main routine functions inside main.c. More...

#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
#include <stdbool.h>
#include <debug.h>
#include <gun.h>
#include <player.h>
#include <time_system.h>
#include <particle_emitterpresets.h>
#include <UI.h>
#include <menu.h>
#include <chunks.h>
#include <camera.h>
#include <maps.h>
#include <enemy.h>
#include <pause.h>
#include <minimap.h>
#include <interactable.h>
#include <logs.h>
#include <hud.h>
#include <game.h>
#include <death.h>
#include <level_transition.h>
#include <mission_briefing.h>

Go to the source code of this file.

Classes

struct  AppResources
 A struct containing the app's resources like the window, renderer, and fonts. More...
 
struct  AppState
 A struct containing the app's states like fps, current scene, and a flag for running. More...
 
struct  AppConfig
 A struct containing the app's configurations like window size, title, and fullscreen mode. More...
 
struct  AppData
 A struct containing the app's resources, state, and configurations. More...
 

Typedefs

typedef bool flag
 
typedef struct AppResources AppResources
 A struct containing the app's resources like the window, renderer, and fonts.
 
typedef struct AppState AppState
 A struct containing the app's states like fps, current scene, and a flag for running.
 
typedef struct AppConfig AppConfig
 A struct containing the app's configurations like window size, title, and fullscreen mode.
 
typedef struct AppData AppData
 A struct containing the app's resources, state, and configurations.
 

Enumerations

enum  AppScene {
  SCENE_MENU , SCENE_GAME , SCENE_PAUSE , SCENE_DEATH ,
  SCENE_MISSION_BRIEFING , SCENE_CONTROLS , SCENE_WIN
}
 An enum containing the app's scenes, like the menu, game, and pause scene. More...
 

Functions

int App_Start ()
 Initializes the app and starts the game loop.
 
int App_PreUpdate ()
 Performs operations before updating the current scene.
 
int App_PostUpdate ()
 Performs operations after updating the current scene.
 
int App_Render ()
 Renders the current scene to the screen.
 
int App_Event_Handler (SDL_Event *event)
 Handles SDL events.
 
int App_Quit ()
 Cleans up resources and quits the application.
 

Variables

AppData app
 A global variable containing the app's resources, state, and configurations.
 

Detailed Description

This file contains the definition of the AppData struct, and the 6 main routine functions inside main.c.

Author
Mango (杜明日)
Date
2025-03-22

Typedef Documentation

◆ AppConfig

typedef struct AppConfig AppConfig

A struct containing the app's configurations like window size, title, and fullscreen mode.

◆ AppData

typedef struct AppData AppData

A struct containing the app's resources, state, and configurations.

Used by the app variable.

◆ AppResources

typedef struct AppResources AppResources

A struct containing the app's resources like the window, renderer, and fonts.

◆ AppState

typedef struct AppState AppState

A struct containing the app's states like fps, current scene, and a flag for running.

◆ flag

typedef bool flag

Enumeration Type Documentation

◆ AppScene

enum AppScene

An enum containing the app's scenes, like the menu, game, and pause scene.

Example for how to handle app scenes in src/App/app_postupdate.c

{
case SCENE_MENU: // Updates the menu logic
case SCENE_GAME: // Updates the game logic
case SCENE_PAUSE: // Updates the pause logic
}
@ SCENE_PAUSE
Pause menu scene.
Definition app.h:56
@ SCENE_GAME
Main gameplay scene.
Definition app.h:55
@ SCENE_MENU
Menu scene of the application.
Definition app.h:54
AppData app
A global variable containing the app's resources, state, and configurations.
AppState state
The app's state.
Definition app.h:109
AppScene currentScene
The current scene.
Definition app.h:83
Enumerator
SCENE_MENU 

Menu scene of the application.

SCENE_GAME 

Main gameplay scene.

SCENE_PAUSE 

Pause menu scene.

SCENE_DEATH 
SCENE_MISSION_BRIEFING 

Death scene.

Mission briefing scene

SCENE_CONTROLS 
SCENE_WIN 

Win scene when mission is accomplished.

Function Documentation

◆ App_Event_Handler()

int App_Event_Handler ( SDL_Event *  event)

Handles SDL events.

Parameters
[in]eventPointer to the SDL event to handle
Returns
int Status code (0 for success, non-zero for error)

◆ App_PostUpdate()

int App_PostUpdate ( )

Performs operations after updating the current scene.

Returns
int Status code (0 for success, non-zero for error)

◆ App_PreUpdate()

int App_PreUpdate ( )

Performs operations before updating the current scene.

Returns
int Status code (0 for success, non-zero for error)

◆ App_Quit()

int App_Quit ( )

Cleans up resources and quits the application.

Returns
int Status code (0 for success, non-zero for error)

◆ App_Render()

int App_Render ( )

Renders the current scene to the screen.

Returns
int Status code (0 for success, non-zero for error)

Renders the current scene to the screen.

Includes the main rendering function and the final rendering to the window. This function is called every frame after all the updating is complete.

Returns
int Status code (0 for success)

◆ App_Start()

int App_Start ( )

Initializes the app and starts the game loop.

Returns
int Status code (0 for success, non-zero for error)

Variable Documentation

◆ app

AppData app
extern

A global variable containing the app's resources, state, and configurations.

Used throughout the application to access central app data.

// Example usages:
if (event == SDL_QUIT) app.state.running = false;
SDL_SetWindowTitle(app.resources.window, app.config.window_title);
SDL_RenderPresent(app.resources.renderer);
char * window_title
The window title.
Definition app.h:90
AppConfig config
The app's configurations.
Definition app.h:110
AppResources resources
The app's resources.
Definition app.h:108
SDL_Renderer * renderer
The SDL renderer.
Definition app.h:68
SDL_Window * window
The SDL window.
Definition app.h:67
bool running
Flag indicating if the app is running.
Definition app.h:80