Advertisement
Kitomas

globals.hpp as of 2024-03-29

Mar 29th, 2024
761
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.29 KB | None | 0 0
  1. #ifndef _GLOBALS_HPP
  2. #define _GLOBALS_HPP
  3.  
  4. #include <kit/all.hpp>
  5. #include <kit/xmp_sfx.hpp>
  6.  
  7.  
  8.  
  9.  
  10. #define WINDOW_TITLE "platformer prototype"
  11. #define CANVSIZ_X 768 //32 tiles wide
  12. #define CANVSIZ_Y 432 //18 tiles tall
  13.  
  14.  
  15.  
  16. //gl_ as in global, not opengl
  17. extern kit::TimerSimple* gl_frameTimer;
  18. extern kit::SoundEngine* gl_snd;
  19. extern kit::Window*      gl_win;
  20. extern kit::BitmapFont*  gl_text;
  21. extern kit::FStr*       _gl_text_fstr;
  22. #define gl_textf(_x, _y, _fmt, _maxLen, ...) \
  23.     gl_text->print((_x), (_y), _gl_text_fstr->fmt(_fmt, __VA_ARGS__), (_maxLen))
  24. //
  25.  
  26.  
  27.  
  28. extern kit::Bitmap* gl_spritesheetPlayer;
  29.  
  30.  
  31.  
  32.  
  33.  
  34. kit::f64 frand();
  35. kit::f32 frandf();
  36.  
  37. kit::f64 frandRange(kit::f64 start, kit::f64 maxDeviation);
  38.  
  39.  
  40.  
  41.  
  42.  
  43. struct SoundEffect { //40B (not including the size of the AudioData class)
  44.   kit::AudioData* sfx = nullptr;
  45.   kit::f32       volL = 1.0f;
  46.   kit::f32       volR = 1.0f;
  47.   kit::f64  speedBase = 1.0 ;
  48.   kit::f64 speedRange = 0.0 ;
  49.   kit::f32        pan = 0.0f;
  50.   kit::u32 _padding32;
  51.  
  52.   SoundEffect(const char* filePath, kit::f32 volume = 1.0f,
  53.                                     kit::f64 _speedRange = 0.0)
  54.   {
  55.     sfx = new kit::AudioData(filePath, gl_snd);
  56.     volL = volume,  volR = volume;
  57.     speedRange = _speedRange;
  58.   }
  59.  
  60.   ~SoundEffect(){ delete sfx; }
  61.  
  62.   kit::s32 play(){
  63.     if(sfx != nullptr){
  64.       if(speedRange < 0.0) speedRange = -speedRange;
  65.       if(!speedRange) return gl_snd->sfxPlay(sfx, volL, volR, 1.0, pan);
  66.       else return gl_snd->sfxPlay(sfx, volL, volR, frandRange(speedBase,speedRange), pan);
  67.     } else {
  68.       return -1;
  69.     }
  70.   }
  71. };
  72.  
  73.  
  74.  
  75.  
  76.  
  77. #define GRAVITY (0.0175f)
  78. #define PLAYER_JUMP_STRENGTH (2.0f)
  79. #define PLAYER_JUMP_CANCEL (0.33f) //multiplier of vel.y when canceling a jump while ascending
  80. #define PLAYER_SPEED (0.020f)
  81. #define PLAYER_SCALE (2.0f)
  82. #define PLAYER_HALF ( (s32)((8*PLAYER_SCALE)/2) ) //half of the character's size, in pixels
  83. #define PLAYER_NEUTRAL (0.1f) //'what +/- range should be considered neutral for vel/acc'
  84. #define PLAYER_AIR_FRICTION (0.5f) //multiplier for acc.x when in mid-air
  85. #define PLAYER_GND_FRICTION (1.0f) //multiplier of PLAYER_SPEED for on-ground deceleration
  86. #define PLAYER_RUN_MUL (0.075f) //vel.x's multiplier when adding to runningState
  87.  
  88.  
  89.  
  90.  
  91.  
  92. #endif /* _GLOBALS_HPP */
  93.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement