Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <globals.hpp>
- #include <stdio.h>
- #include <stdlib.h>
- using namespace kit;
- TimerSimple* gl_frameTimer = nullptr;
- SoundEngine* gl_snd = nullptr;
- Window* gl_win = nullptr;
- BitmapFont* gl_text = nullptr;
- FStr* _gl_text_fstr = nullptr;
- Bitmap* gl_spritesheetPlayer = nullptr;
- void handleInit(){
- gl_frameTimer = new TimerSimple;
- gl_frameTimer->setTimer(0.101);
- srand((u32)time::getTicks());
- gl_snd = new SoundEngine(96);
- gl_snd->streamStart();
- gl_win = new Window(WINDOW_TITLE, 1280, 720,
- WINFLAG_RESIZABLE | WINFLAG_HIDDEN,
- WINPOS_CENTERED, WINPOS_CENTERED,
- CANVSIZ_X, CANVSIZ_Y, false);
- gl_text = new BitmapFont("dat/img/_font8x8.qoi", gl_win);
- _gl_text_fstr = new FStr(4096);
- gl_spritesheetPlayer = new Bitmap("dat/img/spritesheet_player.qoi", gl_win);
- gl_frameTimer->wait(2000);
- gl_win->setVisibility(true);
- gl_win->setFocus(true);
- }
- void handleQuit(){
- if(gl_frameTimer) gl_frameTimer->setTimer(0.015);
- if(gl_snd){
- gl_snd->musicStop();
- gl_snd->sfxStopAll();
- }
- delete _gl_text_fstr;
- delete gl_text;
- delete gl_win;
- delete gl_spritesheetPlayer;
- if(gl_frameTimer) gl_frameTimer->wait(2000);
- delete gl_frameTimer;
- }
- extern int gameMain(int argc, char** argv);
- int main(int argc, char** argv){ try {
- handleInit();
- int result = gameMain(argc, argv);
- handleQuit();
- return result;
- } catch(const char* errorText){
- #ifdef _DEBUG
- printf("FATAL EXCEPTION OCCURRED!: \"%s\"\n", errorText);
- #else
- showMessageBox(errorText, "FATAL EXCEPTION OCCURRED! COMPLAIN TO THE DEV! (lol)", MSGBOX_ICN_ERROR);
- #endif /* _DEBUG */
- return -1;
- }}
- f64 frand(){
- u32 value = (rand()<<15) | rand();
- return (f64)value/(KIT_U32_MAX>>2);
- }
- f32 frandf(){
- u32 value = (rand()<<15) | rand();
- return (f32)value/(KIT_U32_MAX>>2);
- }
- f64 frandRange(f64 start, f64 maxDeviation){
- return start + (frand()*2.0-1.0)*maxDeviation;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement