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>
- #define WINDOW_TITLE "platformer prototype"
- #define CANVSIZ_X 768 //32 tiles wide
- #define CANVSIZ_Y 432 //18 tiles tall
- //gl_ as in global, not opengl
- extern kit::TimerSimple* gl_frameTimer;
- extern kit::SoundEngine* gl_snd;
- extern kit::Window* gl_win;
- extern kit::BitmapFont* gl_text;
- extern kit::FStr* _gl_text_fstr;
- #define gl_textf(_x, _y, _fmt, _maxLen, ...) \
- gl_text->print((_x), (_y), _gl_text_fstr->fmt(_fmt, __VA_ARGS__), (_maxLen))
- //
- extern kit::Bitmap* gl_spritesheetPlayer;
- 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){
- 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);
- } else {
- return -1;
- }
- }
- };
- #define GRAVITY (0.0175f)
- #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
- #endif /* _GLOBALS_HPP */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement