Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef _GLOBALS_HPP
- #define _GLOBALS_HPP
- #include <kit/all.hpp>
- #include <kit/xmp_sfx.hpp>
- /* notes:
- always use a mutex when accessing soundengine, as it's used by >1 thread
- player should be able to step up on a half tile as if they were stairs
- scene states should be able to change tiles
- text boxes should appear when close to certain objects
- have thread that manages music and sfx
- add in cutscene image slideshow things
- be able to change scene after cutscene
- use RLE when storing scene data
- tweak "visited_before" to be a number that counts down deaths, instead of a bool
- if ambient track fails to start, (while locked) stop a track to make space for it (use forced stop!)
- have player animation frame override
- */
- #define _getnumallocs printf("line %i: %llu\n",__LINE__,memory::getNumAllocations()-2);
- #define WINDOW_TITLE "platformer prototype"
- #define CANVSIZ_X 768 //32 tiles wide (assuming tiles are 24x24)
- #define CANVSIZ_Y 432 //18 tiles tall
- #define TILESIZ_X 32
- #define TILESIZ_Y 18
- #define lengthof(_array, _type) (sizeof(_array)/sizeof(_type))
- #define memset0( _array ) kit::memory::set((_array), 0, sizeof(_array))
- #define memset0s(_array, _size) kit::memory::set((_array), 0, (_size) )
- #define NULLDELETE(_ptr_to_thing) { delete _ptr_to_thing; _ptr_to_thing = nullptr; }
- //#define GRAVITY (0.0175f)
- #define GRAVITY (0.0195f)
- #define PLAYER_JUMP_STRENGTH (2.0f)
- #define PLAYER_JUMP_CANCEL (0.33f) //multiplier of vel.y when canceling a jump while ascending
- #define PLAYER_SPEED (0.020f)
- #define PLAYER_SCALE (2.0f)
- #define PLAYER_HALF ( (s32)((8*PLAYER_SCALE)/2) ) //half of the character's size, in pixels
- #define PLAYER_NEUTRAL (0.1f) //'what +/- range should be considered neutral for vel/acc'
- #define PLAYER_AIR_FRICTION (0.5f) //multiplier for acc.x when in mid-air
- #define PLAYER_GND_FRICTION (1.0f) //multiplier of PLAYER_SPEED for on-ground deceleration
- #define PLAYER_RUN_MUL (0.075f) //vel.x's multiplier when adding to runningState
- //(gl_ as in [gl]obal, not open[gl])
- extern kit::TimerSimple* gl_frameTimer;
- extern kit::SoundEngine* gl_snd;
- extern kit::MutexSimple* gl_snd_lock;
- extern kit::Window* gl_win;
- extern kit::BitmapFont* gl_text;
- extern kit::FStr* gl_fstr;
- #define gl_textf(_x, _y, _fmt, ...) \
- gl_text->print((_x), (_y), gl_fstr->fmt(_fmt, __VA_ARGS__), 0)
- #define gl_textfs(_x, _y, _fmt, _maxLen, ...) \
- gl_text->print((_x), (_y), gl_fstr->fmt(_fmt, __VA_ARGS__), (_maxLen))
- extern kit::Bitmap* gl_spritesheetPlayer;
- struct Scene;
- #define gl_scenes_len 1
- #define gl_tilesets_len 1
- extern kit::u16 gl_sceneCurrent; //id for currently active scene
- extern Scene gl_scenes[gl_scenes_len];
- extern kit::Bitmap* gl_tilesets[gl_tilesets_len];
- extern kit::Bitmap* gl_tileset_missing;
- kit::f64 frand();
- kit::f32 frandf();
- kit::f64 frandRange(kit::f64 start, kit::f64 maxDeviation);
- struct SoundEffect { //40B (not including the size of the AudioData class)
- kit::AudioData* sfx = nullptr;
- kit::f32 volL = 1.0f;
- kit::f32 volR = 1.0f;
- kit::f64 speedBase = 1.0 ;
- kit::f64 speedRange = 0.0 ;
- kit::f32 pan = 0.0f;
- kit::u32 _padding32;
- SoundEffect(const char* filePath, kit::f32 volume = 1.0f,
- kit::f64 _speedRange = 0.0)
- {
- sfx = new kit::AudioData(filePath, gl_snd);
- volL = volume, volR = volume;
- speedRange = _speedRange;
- }
- ~SoundEffect(){ delete sfx; }
- kit::s32 play(){
- if(sfx != nullptr){
- gl_snd_lock->lock(true);
- if(speedRange < 0.0) speedRange = -speedRange;
- if(!speedRange) return gl_snd->sfxPlay(sfx, volL, volR, 1.0, pan);
- else return gl_snd->sfxPlay(sfx, volL, volR, frandRange(speedBase,speedRange), pan);
- gl_snd_lock->lock(false);
- } else {
- return -1;
- }
- }
- };
- #endif /* _GLOBALS_HPP */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement