├── .gitignore ├── LICENSE.md ├── README.md ├── docs ├── README.md └── _config.yml ├── exercices └── 2D Particle System │ ├── Game │ ├── SDL2.dll │ ├── SDL2_image.dll │ ├── SDL2_mixer.dll │ ├── SDL2_ttf.dll │ ├── config.xml │ ├── libFLAC-8.dll │ ├── libjpeg-9.dll │ ├── libmikmod-2.dll │ ├── libmodplug-1.dll │ ├── libogg-0.dll │ ├── libpng16-16.dll │ ├── libtiff-5.dll │ ├── libvorbis-0.dll │ ├── libvorbisfile-3.dll │ ├── libwebp-4.dll │ ├── psystem_config │ ├── smpeg2.dll │ ├── textures │ │ ├── particles.png │ │ └── torch.png │ └── zlib1.dll │ ├── Motor2D │ ├── Emitter.cpp │ ├── Emitter.h │ ├── Motor2D.vcxproj │ ├── Motor2D.vcxproj.filters │ ├── Particle.cpp │ ├── Particle.h │ ├── ParticlePool.cpp │ ├── ParticlePool.h │ ├── PugiXml │ │ ├── readme.txt │ │ └── src │ │ │ ├── pugiconfig.hpp │ │ │ ├── pugixml.cpp │ │ │ └── pugixml.hpp │ ├── SDL │ │ ├── BUGS.txt │ │ ├── COPYING.txt │ │ ├── README-SDL.txt │ │ ├── README.txt │ │ ├── WhatsNew.txt │ │ ├── include │ │ │ ├── SDL.h │ │ │ ├── SDL_assert.h │ │ │ ├── SDL_atomic.h │ │ │ ├── SDL_audio.h │ │ │ ├── SDL_bits.h │ │ │ ├── SDL_blendmode.h │ │ │ ├── SDL_clipboard.h │ │ │ ├── SDL_config.h │ │ │ ├── SDL_cpuinfo.h │ │ │ ├── SDL_egl.h │ │ │ ├── SDL_endian.h │ │ │ ├── SDL_error.h │ │ │ ├── SDL_events.h │ │ │ ├── SDL_filesystem.h │ │ │ ├── SDL_gamecontroller.h │ │ │ ├── SDL_gesture.h │ │ │ ├── SDL_haptic.h │ │ │ ├── SDL_hints.h │ │ │ ├── SDL_joystick.h │ │ │ ├── SDL_keyboard.h │ │ │ ├── SDL_keycode.h │ │ │ ├── SDL_loadso.h │ │ │ ├── SDL_log.h │ │ │ ├── SDL_main.h │ │ │ ├── SDL_messagebox.h │ │ │ ├── SDL_mouse.h │ │ │ ├── SDL_mutex.h │ │ │ ├── SDL_name.h │ │ │ ├── SDL_opengl.h │ │ │ ├── SDL_opengl_glext.h │ │ │ ├── SDL_opengles.h │ │ │ ├── SDL_opengles2.h │ │ │ ├── SDL_opengles2_gl2.h │ │ │ ├── SDL_opengles2_gl2ext.h │ │ │ ├── SDL_opengles2_gl2platform.h │ │ │ ├── SDL_opengles2_khrplatform.h │ │ │ ├── SDL_pixels.h │ │ │ ├── SDL_platform.h │ │ │ ├── SDL_power.h │ │ │ ├── SDL_quit.h │ │ │ ├── SDL_rect.h │ │ │ ├── SDL_render.h │ │ │ ├── SDL_revision.h │ │ │ ├── SDL_rwops.h │ │ │ ├── SDL_scancode.h │ │ │ ├── SDL_shape.h │ │ │ ├── SDL_stdinc.h │ │ │ ├── SDL_surface.h │ │ │ ├── SDL_system.h │ │ │ ├── SDL_syswm.h │ │ │ ├── SDL_test.h │ │ │ ├── SDL_test_assert.h │ │ │ ├── SDL_test_common.h │ │ │ ├── SDL_test_compare.h │ │ │ ├── SDL_test_crc32.h │ │ │ ├── SDL_test_font.h │ │ │ ├── SDL_test_fuzzer.h │ │ │ ├── SDL_test_harness.h │ │ │ ├── SDL_test_images.h │ │ │ ├── SDL_test_log.h │ │ │ ├── SDL_test_md5.h │ │ │ ├── SDL_test_random.h │ │ │ ├── SDL_thread.h │ │ │ ├── SDL_timer.h │ │ │ ├── SDL_touch.h │ │ │ ├── SDL_types.h │ │ │ ├── SDL_version.h │ │ │ ├── SDL_video.h │ │ │ ├── begin_code.h │ │ │ └── close_code.h │ │ └── libx86 │ │ │ ├── SDL2.lib │ │ │ └── SDL2main.lib │ ├── SDL_image │ │ ├── CHANGES.txt │ │ ├── COPYING.txt │ │ ├── README.txt │ │ ├── include │ │ │ └── SDL_image.h │ │ └── libx86 │ │ │ └── SDL2_image.lib │ ├── SDL_mixer │ │ ├── CHANGES.txt │ │ ├── COPYING.txt │ │ ├── README.txt │ │ ├── include │ │ │ └── SDL_mixer.h │ │ └── libx86 │ │ │ └── SDL2_mixer.lib │ ├── j1App.cpp │ ├── j1App.h │ ├── j1Input.cpp │ ├── j1Input.h │ ├── j1Main.cpp │ ├── j1Module.h │ ├── j1ParticleSystem.cpp │ ├── j1ParticleSystem.h │ ├── j1PerfTimer.cpp │ ├── j1PerfTimer.h │ ├── j1Render.cpp │ ├── j1Render.h │ ├── j1Scene.cpp │ ├── j1Scene.h │ ├── j1Textures.cpp │ ├── j1Textures.h │ ├── j1Timer.cpp │ ├── j1Timer.h │ ├── j1Window.cpp │ ├── j1Window.h │ ├── p2Defs.h │ ├── p2Log.cpp │ ├── p2Log.h │ └── p2Point.h │ └── Particle System.sln └── full_code └── 2D Particle System ├── Brofiler └── Brofiler.exe ├── Game ├── ProfilerCore32.dll ├── SDL2.dll ├── SDL2_image.dll ├── SDL2_mixer.dll ├── SDL2_ttf.dll ├── config.xml ├── libFLAC-8.dll ├── libjpeg-9.dll ├── libmikmod-2.dll ├── libmodplug-1.dll ├── libogg-0.dll ├── libpng16-16.dll ├── libtiff-5.dll ├── libvorbis-0.dll ├── libvorbisfile-3.dll ├── libwebp-4.dll ├── psystem_config.xml ├── smpeg2.dll ├── textures │ ├── particles.png │ └── torch.png └── zlib1.dll ├── Motor2D ├── Brofiler │ ├── Brofiler.h │ ├── LICENSE │ ├── ProfilerCore32.lib │ └── README.md ├── Emitter.cpp ├── Emitter.h ├── Motor2D.vcxproj ├── Motor2D.vcxproj.filters ├── Particle.cpp ├── Particle.h ├── ParticlePool.cpp ├── ParticlePool.h ├── PugiXml │ ├── readme.txt │ └── src │ │ ├── pugiconfig.hpp │ │ ├── pugixml.cpp │ │ └── pugixml.hpp ├── SDL │ ├── BUGS.txt │ ├── COPYING.txt │ ├── README-SDL.txt │ ├── README.txt │ ├── WhatsNew.txt │ ├── include │ │ ├── SDL.h │ │ ├── SDL_assert.h │ │ ├── SDL_atomic.h │ │ ├── SDL_audio.h │ │ ├── SDL_bits.h │ │ ├── SDL_blendmode.h │ │ ├── SDL_clipboard.h │ │ ├── SDL_config.h │ │ ├── SDL_cpuinfo.h │ │ ├── SDL_egl.h │ │ ├── SDL_endian.h │ │ ├── SDL_error.h │ │ ├── SDL_events.h │ │ ├── SDL_filesystem.h │ │ ├── SDL_gamecontroller.h │ │ ├── SDL_gesture.h │ │ ├── SDL_haptic.h │ │ ├── SDL_hints.h │ │ ├── SDL_joystick.h │ │ ├── SDL_keyboard.h │ │ ├── SDL_keycode.h │ │ ├── SDL_loadso.h │ │ ├── SDL_log.h │ │ ├── SDL_main.h │ │ ├── SDL_messagebox.h │ │ ├── SDL_mouse.h │ │ ├── SDL_mutex.h │ │ ├── SDL_name.h │ │ ├── SDL_opengl.h │ │ ├── SDL_opengl_glext.h │ │ ├── SDL_opengles.h │ │ ├── SDL_opengles2.h │ │ ├── SDL_opengles2_gl2.h │ │ ├── SDL_opengles2_gl2ext.h │ │ ├── SDL_opengles2_gl2platform.h │ │ ├── SDL_opengles2_khrplatform.h │ │ ├── SDL_pixels.h │ │ ├── SDL_platform.h │ │ ├── SDL_power.h │ │ ├── SDL_quit.h │ │ ├── SDL_rect.h │ │ ├── SDL_render.h │ │ ├── SDL_revision.h │ │ ├── SDL_rwops.h │ │ ├── SDL_scancode.h │ │ ├── SDL_shape.h │ │ ├── SDL_stdinc.h │ │ ├── SDL_surface.h │ │ ├── SDL_system.h │ │ ├── SDL_syswm.h │ │ ├── SDL_test.h │ │ ├── SDL_test_assert.h │ │ ├── SDL_test_common.h │ │ ├── SDL_test_compare.h │ │ ├── SDL_test_crc32.h │ │ ├── SDL_test_font.h │ │ ├── SDL_test_fuzzer.h │ │ ├── SDL_test_harness.h │ │ ├── SDL_test_images.h │ │ ├── SDL_test_log.h │ │ ├── SDL_test_md5.h │ │ ├── SDL_test_random.h │ │ ├── SDL_thread.h │ │ ├── SDL_timer.h │ │ ├── SDL_touch.h │ │ ├── SDL_types.h │ │ ├── SDL_version.h │ │ ├── SDL_video.h │ │ ├── begin_code.h │ │ └── close_code.h │ └── libx86 │ │ ├── SDL2.lib │ │ └── SDL2main.lib ├── SDL_image │ ├── CHANGES.txt │ ├── COPYING.txt │ ├── README.txt │ ├── include │ │ └── SDL_image.h │ └── libx86 │ │ └── SDL2_image.lib ├── SDL_mixer │ ├── CHANGES.txt │ ├── COPYING.txt │ ├── README.txt │ ├── include │ │ └── SDL_mixer.h │ └── libx86 │ │ └── SDL2_mixer.lib ├── j1App.cpp ├── j1App.h ├── j1Input.cpp ├── j1Input.h ├── j1Main.cpp ├── j1Module.h ├── j1ParticleSystem.cpp ├── j1ParticleSystem.h ├── j1PerfTimer.cpp ├── j1PerfTimer.h ├── j1Render.cpp ├── j1Render.h ├── j1Scene.cpp ├── j1Scene.h ├── j1Textures.cpp ├── j1Textures.h ├── j1Timer.cpp ├── j1Timer.h ├── j1Window.cpp ├── j1Window.h ├── mmgr │ ├── mmgr.cpp │ ├── mmgr.h │ ├── nommgr.h │ └── readme.txt ├── p2Defs.h ├── p2Log.cpp ├── p2Log.h └── p2Point.h └── Particle System.sln /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 nintervik 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/README.md -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman 2 | 3 | title: [2D Particle System] 4 | description: [A tutorial on how to implement a 2D particle system in computer graphics] 5 | show_downloads: ["true"] 6 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/SDL2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/SDL2.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/SDL2_image.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/SDL2_image.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/SDL2_mixer.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/SDL2_mixer.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/SDL2_ttf.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/SDL2_ttf.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Particle System 6 | UPC 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/libFLAC-8.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/libFLAC-8.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/libjpeg-9.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/libjpeg-9.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/libmikmod-2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/libmikmod-2.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/libmodplug-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/libmodplug-1.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/libogg-0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/libogg-0.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/libpng16-16.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/libpng16-16.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/libtiff-5.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/libtiff-5.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/libvorbis-0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/libvorbis-0.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/libvorbisfile-3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/libvorbisfile-3.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/libwebp-4.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/libwebp-4.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/psystem_config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/smpeg2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/smpeg2.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/textures/particles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/textures/particles.png -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/textures/torch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/textures/torch.png -------------------------------------------------------------------------------- /exercices/2D Particle System/Game/zlib1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Game/zlib1.dll -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/Emitter.h: -------------------------------------------------------------------------------- 1 | #ifndef __EMITTER_H__ 2 | #define __EMITTER_H__ 3 | 4 | #include "p2Point.h" 5 | #include "j1ParticleSystem.h" 6 | #include "ParticlePool.h" 7 | #include "j1PerfTimer.h" 8 | #include "SDL/include/SDL.h" 9 | 10 | struct SDL_Texture; 11 | class ParticlePool; 12 | struct EmitterData; 13 | 14 | class Emitter 15 | { 16 | private: 17 | 18 | // Particles size and movement 19 | fPoint pos = { 0.0f, 0.0f }; 20 | fPoint angleRange = { 0.0f, 360.0f }; 21 | float startSpeed = 0.0f; 22 | float endSpeed = 0.0f; 23 | float startSize = 0.0f; 24 | float endSize = 0.0f; 25 | double rotSpeed = 0; 26 | 27 | // Particles emission 28 | int emissionRate = 0; 29 | uint emitNumber = 0u; 30 | uint emitVariance = 0u; 31 | uint maxParticleLife = 0u; 32 | uint maxParticlesPerFrame = 0u; 33 | 34 | // Pool 35 | ParticlePool* emitterPool = nullptr; 36 | int poolSize = 0; 37 | 38 | // Emission time 39 | j1PerfTimer stopTimer; 40 | j1PerfTimer emissionTimer; 41 | j1PerfTimer lifeTimer; 42 | double stopTime = 0.0f; 43 | double emissionTime = 0.0f; 44 | double lifetime = -1.0f; 45 | bool active = false; 46 | 47 | // Color and render properties 48 | SDL_Color startColor = { 0, 0, 0, 0 }; 49 | SDL_Color endColor = { 0, 0, 0, 0 }; 50 | SDL_Rect textureRect; 51 | SDL_BlendMode blendMode = SDL_BlendMode::SDL_BLENDMODE_NONE; 52 | float timeStep = 0.0f; 53 | 54 | // Random control parameters 55 | fPoint rotSpeedRand = { 0.0f, 0.0f }; 56 | fPoint startSpeedRand = { 0.0f, 0.0f }; 57 | fPoint endSpeedRand = { 0.0f, 0.0f }; 58 | fPoint emitVarianceRand = { 0.0f, 0.0f }; 59 | fPoint lifeRand = { 0.0f, 0.0f }; 60 | fPoint startSizeRand = { 0.0f, 0.0f }; 61 | fPoint endSizeRand = { 0.0f, 0.0f }; 62 | 63 | public: 64 | 65 | bool toDestroy = false; 66 | 67 | Emitter(fPoint pos, EmitterData data); 68 | // fPoint pos, uint emitNumber, uint emitVariance, uint maxParticleLife, fPoint angleRange, double rotSpeed, float maxSpeed, float startSize, float endSize, SDL_Rect textureRect, SDL_Color startColor = { 0, 0, 0, 0 }, SDL_Color endColor = { 0, 0, 0, 0 }, SDL_BlendMode blendMode = SDL_BlendMode::SDL_BLENDMODE_NONE, double lifetime = -1.0f 69 | virtual ~Emitter(); 70 | 71 | void Update(float dt); 72 | 73 | // Generates random number between given range 74 | float RangeRandomNum(float min = -1.0f, float max = 1.0f); 75 | 76 | // Returns emitter pool size 77 | int GetPoolSize() const; 78 | 79 | // Starts emission specified by timer, if not emission time is infinite 80 | void StartEmission(double timer = -1.0f); 81 | 82 | // Stops emission specified by timer, if not emission stop time is infinite 83 | void StopEmission(double timer = 0.0f); 84 | 85 | // Emitter move methods 86 | void MoveEmitter(fPoint newPos); 87 | fPoint GetEmitterPos() const; 88 | }; 89 | 90 | #endif -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/Particle.h: -------------------------------------------------------------------------------- 1 | #ifndef __PARTICLE_H__ 2 | #define __PARTICLE_H__ 3 | 4 | #include "p2Point.h" 5 | #include "SDL/include/SDL.h" 6 | 7 | #define MIN_LIFE_TO_INTERPOLATE 15 8 | 9 | struct SDL_Texture; 10 | 11 | class Particle 12 | { 13 | private: 14 | 15 | /* This is the only variable we care about no matter if 16 | the particle is alive or dead */ 17 | uint life = 0; 18 | 19 | struct Vortex 20 | { 21 | fPoint pos = { 0.0f, 0.0f }; 22 | float speed = 0.0f; 23 | float scale = 0.0f; 24 | } vortex; 25 | 26 | union ParticleInfo 27 | { 28 | /* This struct holds the state of the particle when 29 | it's being update (it's still alive).*/ 30 | struct ParticleState 31 | { 32 | uint startLife; 33 | fPoint pos; 34 | fPoint startVel; 35 | fPoint endVel; 36 | fPoint currentVel; 37 | float currentSize, startSize, endSize; 38 | float ageRatio; 39 | float angle; 40 | double startRotSpeed; 41 | double currentRotSpeed; 42 | SDL_Rect pRect; 43 | SDL_Rect rectSize; 44 | SDL_Color startColor; 45 | SDL_Color endColor; 46 | SDL_BlendMode blendMode; 47 | float t; 48 | 49 | ParticleState() {} 50 | 51 | } pLive; 52 | 53 | /* If the particle is dead, then the 'next' member comes 54 | into play and the struct it's not used. This pointer 55 | called 'next' holds a pointer to the next available 56 | particle after this one. */ 57 | Particle* next; 58 | 59 | ParticleInfo() {} 60 | } pState; 61 | 62 | public: 63 | 64 | Particle(); 65 | 66 | // Initializes new generated particle 67 | void Init(fPoint pos, float startSpeed, float endSpeed, float angle, double rotSpeed, float startSize, float endSize, uint life, SDL_Rect textureRect, SDL_Color startColor, SDL_Color endColor, SDL_BlendMode blendMode); 68 | 69 | // Generic methods 70 | void Update(float dt); 71 | void Draw(); 72 | bool IsAlive(); 73 | 74 | // Particle pointer methods 75 | Particle* GetNext(); 76 | void SetNext(Particle* next); 77 | 78 | float InterpolateBetweenRange(float min, float timeStep, float max); 79 | 80 | // Adds a vortex to the system 81 | void AddVortex(fPoint pos, float speed, float scale); 82 | 83 | /* Calculates particle position considering its velocity 84 | and if there's a vortex in the system */ 85 | void CalculateParticlePos(float dt); 86 | }; 87 | 88 | #endif -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/ParticlePool.cpp: -------------------------------------------------------------------------------- 1 | #include "ParticlePool.h" 2 | #include 3 | 4 | 5 | // This pool constructor sets our particles to available 6 | ParticlePool::ParticlePool(Emitter* emitter) 7 | { 8 | /* TODO 2.2: Convert particleArray into a free list: 9 | - Make the firstAvailable pointer point to the first element of the pool 10 | - Make each particle inside the pool point to the next one. Use the SetNext() method 11 | - Make the last particle point to nullptr 12 | */ 13 | 14 | /* TODO 3.2 - Allocate memory for the pool: 15 | - Use GetPoolSize() from the given emitter. 16 | - Remember to free the memory! 17 | */ 18 | } 19 | 20 | ParticlePool::~ParticlePool() 21 | { 22 | 23 | } 24 | 25 | void ParticlePool::Generate(fPoint pos, float startSpeed, float endSpeed, float angle, float rotSpeed, float startSize, float endSize, uint life, SDL_Rect textureRect, SDL_Color startColor, SDL_Color endColor, SDL_BlendMode blendMode) 26 | { 27 | /* TODO 2.3 Generate a new particle from the pool 28 | - Use firstAvailable to Init the particle. 29 | - But remember to move the firstAvailable pointer to the next particles so we don't lose track of it. 30 | - Also check first that the pool is not empty befor doing anything. Use assert for this. 31 | */ 32 | } 33 | 34 | bool ParticlePool::Update(float dt) 35 | { 36 | bool ret = false; 37 | 38 | /* TODO 2.4 Update and draw living particles in the pool. 39 | - If it's alive update it, draw it and make sure to return true 40 | - If a particle is dead it becomes the first available in the pool. 41 | Use IsAlive() method to check this. 42 | */ 43 | 44 | return ret; 45 | } -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/ParticlePool.h: -------------------------------------------------------------------------------- 1 | #ifndef __PARTICLE_POOL_H__ 2 | #define __PARTICLE_POOL_H__ 3 | 4 | #include "Particle.h" 5 | #include "Emitter.h" 6 | #include "p2Point.h" 7 | #include 8 | 9 | class Emitter; 10 | 11 | class ParticlePool 12 | { 13 | private: 14 | 15 | int poolSize = 0; 16 | Particle* firstAvailable; 17 | 18 | // TODO 2.1: Declare an static array of 100 particles 19 | 20 | 21 | 22 | public: 23 | 24 | ParticlePool(Emitter* emitter); 25 | virtual ~ParticlePool(); 26 | 27 | //Generates a new particle each time it's called 28 | void Generate(fPoint pos, float startSpeed, float endSpeed, float angle, float rotSpeed, float startSize, float endSize, uint life, SDL_Rect textureRect, SDL_Color startColor, SDL_Color endColor, SDL_BlendMode blendMode); 29 | 30 | // Update (move and draw) particles in the pool. If there are no particles alive returns false 31 | bool Update(float dt); 32 | }; 33 | 34 | #endif -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/PugiXml/readme.txt: -------------------------------------------------------------------------------- 1 | pugixml 1.6 - an XML processing library 2 | 3 | Copyright (C) 2006-2015, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) 4 | Report bugs and download new versions at http://pugixml.org/ 5 | 6 | This is the distribution of pugixml, which is a C++ XML processing library, 7 | which consists of a DOM-like interface with rich traversal/modification 8 | capabilities, an extremely fast XML parser which constructs the DOM tree from 9 | an XML file/buffer, and an XPath 1.0 implementation for complex data-driven 10 | tree queries. Full Unicode support is also available, with Unicode interface 11 | variants and conversions between different Unicode encodings (which happen 12 | automatically during parsing/saving). 13 | 14 | The distribution contains the following folders: 15 | 16 | contrib/ - various contributions to pugixml 17 | 18 | docs/ - documentation 19 | docs/samples - pugixml usage examples 20 | docs/quickstart.html - quick start guide 21 | docs/manual.html - complete manual 22 | 23 | scripts/ - project files for IDE/build systems 24 | 25 | src/ - header and source files 26 | 27 | readme.txt - this file. 28 | 29 | This library is distributed under the MIT License: 30 | 31 | Copyright (c) 2006-2015 Arseny Kapoulkine 32 | 33 | Permission is hereby granted, free of charge, to any person 34 | obtaining a copy of this software and associated documentation 35 | files (the "Software"), to deal in the Software without 36 | restriction, including without limitation the rights to use, 37 | copy, modify, merge, publish, distribute, sublicense, and/or sell 38 | copies of the Software, and to permit persons to whom the 39 | Software is furnished to do so, subject to the following 40 | conditions: 41 | 42 | The above copyright notice and this permission notice shall be 43 | included in all copies or substantial portions of the Software. 44 | 45 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 46 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 47 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 48 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 49 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 50 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 51 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 52 | OTHER DEALINGS IN THE SOFTWARE. 53 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/PugiXml/src/pugiconfig.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * pugixml parser - version 1.6 3 | * -------------------------------------------------------- 4 | * Copyright (C) 2006-2015, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) 5 | * Report bugs and download new versions at http://pugixml.org/ 6 | * 7 | * This library is distributed under the MIT License. See notice at the end 8 | * of this file. 9 | * 10 | * This work is based on the pugxml parser, which is: 11 | * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) 12 | */ 13 | 14 | #ifndef HEADER_PUGICONFIG_HPP 15 | #define HEADER_PUGICONFIG_HPP 16 | 17 | // Uncomment this to enable wchar_t mode 18 | // #define PUGIXML_WCHAR_MODE 19 | 20 | // Uncomment this to disable XPath 21 | // #define PUGIXML_NO_XPATH 22 | 23 | // Uncomment this to disable STL 24 | // #define PUGIXML_NO_STL 25 | 26 | // Uncomment this to disable exceptions 27 | // #define PUGIXML_NO_EXCEPTIONS 28 | 29 | // Set this to control attributes for public classes/functions, i.e.: 30 | // #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL 31 | // #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL 32 | // #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall 33 | // In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead 34 | 35 | // Tune these constants to adjust memory-related behavior 36 | // #define PUGIXML_MEMORY_PAGE_SIZE 32768 37 | // #define PUGIXML_MEMORY_OUTPUT_STACK 10240 38 | // #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 39 | 40 | // Uncomment this to switch to header-only version 41 | // #define PUGIXML_HEADER_ONLY 42 | 43 | // Uncomment this to enable long long support 44 | // #define PUGIXML_HAS_LONG_LONG 45 | 46 | #endif 47 | 48 | /** 49 | * Copyright (c) 2006-2015 Arseny Kapoulkine 50 | * 51 | * Permission is hereby granted, free of charge, to any person 52 | * obtaining a copy of this software and associated documentation 53 | * files (the "Software"), to deal in the Software without 54 | * restriction, including without limitation the rights to use, 55 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 56 | * copies of the Software, and to permit persons to whom the 57 | * Software is furnished to do so, subject to the following 58 | * conditions: 59 | * 60 | * The above copyright notice and this permission notice shall be 61 | * included in all copies or substantial portions of the Software. 62 | * 63 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 64 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 65 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 66 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 67 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 68 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 69 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 70 | * OTHER DEALINGS IN THE SOFTWARE. 71 | */ 72 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/BUGS.txt: -------------------------------------------------------------------------------- 1 | 2 | Bugs are now managed in the SDL bug tracker, here: 3 | 4 | http://bugzilla.libsdl.org/ 5 | 6 | You may report bugs there, and search to see if a given issue has already 7 | been reported, discussed, and maybe even fixed. 8 | 9 | 10 | You may also find help on the SDL mailing list. Subscription information: 11 | 12 | http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org 13 | 14 | Bug reports are welcome here, but we really appreciate if you use Bugzilla, as 15 | bugs discussed on the mailing list may be forgotten or missed. 16 | 17 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/COPYING.txt: -------------------------------------------------------------------------------- 1 | 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | 21 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/README-SDL.txt: -------------------------------------------------------------------------------- 1 | 2 | Please distribute this file with the SDL runtime environment: 3 | 4 | The Simple DirectMedia Layer (SDL for short) is a cross-platform library 5 | designed to make it easy to write multi-media software, such as games and 6 | emulators. 7 | 8 | The Simple DirectMedia Layer library source code is available from: 9 | http://www.libsdl.org/ 10 | 11 | This library is distributed under the terms of the zlib license: 12 | http://www.zlib.net/zlib_license.html 13 | 14 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/README.txt: -------------------------------------------------------------------------------- 1 | 2 | Simple DirectMedia Layer 3 | 4 | (SDL) 5 | 6 | Version 2.0 7 | 8 | --- 9 | http://www.libsdl.org/ 10 | 11 | Simple DirectMedia Layer is a cross-platform development library designed 12 | to provide low level access to audio, keyboard, mouse, joystick, and graphics 13 | hardware via OpenGL and Direct3D. It is used by video playback software, 14 | emulators, and popular games including Valve's award winning catalog 15 | and many Humble Bundle games. 16 | 17 | SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. 18 | Support for other platforms may be found in the source code. 19 | 20 | SDL is written in C, works natively with C++, and there are bindings 21 | available for several other languages, including C# and Python. 22 | 23 | This library is distributed under the zlib license, which can be found 24 | in the file "COPYING.txt". 25 | 26 | The best way to learn how to use SDL is to check out the header files in 27 | the "include" subdirectory and the programs in the "test" subdirectory. 28 | The header files and test programs are well commented and always up to date. 29 | More documentation and FAQs are available online at: 30 | http://wiki.libsdl.org/ 31 | 32 | If you need help with the library, or just want to discuss SDL related 33 | issues, you can join the developers mailing list: 34 | http://www.libsdl.org/mailing-list.php 35 | 36 | If you want to report bugs or contribute patches, please submit them to 37 | bugzilla: 38 | http://bugzilla.libsdl.org/ 39 | 40 | Enjoy! 41 | Sam Lantinga (slouken@libsdl.org) 42 | 43 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_bits.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_bits.h 24 | * 25 | * Functions for fiddling with bits and bitmasks. 26 | */ 27 | 28 | #ifndef _SDL_bits_h 29 | #define _SDL_bits_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \file SDL_bits.h 41 | */ 42 | 43 | /** 44 | * Get the index of the most significant bit. Result is undefined when called 45 | * with 0. This operation can also be stated as "count leading zeroes" and 46 | * "log base 2". 47 | * 48 | * \return Index of the most significant bit, or -1 if the value is 0. 49 | */ 50 | SDL_FORCE_INLINE int 51 | SDL_MostSignificantBitIndex32(Uint32 x) 52 | { 53 | #if defined(__GNUC__) && __GNUC__ >= 4 54 | /* Count Leading Zeroes builtin in GCC. 55 | * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html 56 | */ 57 | if (x == 0) { 58 | return -1; 59 | } 60 | return 31 - __builtin_clz(x); 61 | #else 62 | /* Based off of Bit Twiddling Hacks by Sean Eron Anderson 63 | * , released in the public domain. 64 | * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog 65 | */ 66 | const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; 67 | const int S[] = {1, 2, 4, 8, 16}; 68 | 69 | int msbIndex = 0; 70 | int i; 71 | 72 | if (x == 0) { 73 | return -1; 74 | } 75 | 76 | for (i = 4; i >= 0; i--) 77 | { 78 | if (x & b[i]) 79 | { 80 | x >>= S[i]; 81 | msbIndex |= S[i]; 82 | } 83 | } 84 | 85 | return msbIndex; 86 | #endif 87 | } 88 | 89 | /* Ends C function definitions when using C++ */ 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | #include "close_code.h" 94 | 95 | #endif /* _SDL_bits_h */ 96 | 97 | /* vi: set ts=4 sw=4 expandtab: */ 98 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_blendmode.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_blendmode.h 24 | * 25 | * Header file declaring the SDL_BlendMode enumeration 26 | */ 27 | 28 | #ifndef _SDL_blendmode_h 29 | #define _SDL_blendmode_h 30 | 31 | #include "begin_code.h" 32 | /* Set up for C function definitions, even when using C++ */ 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** 38 | * \brief The blend mode used in SDL_RenderCopy() and drawing operations. 39 | */ 40 | typedef enum 41 | { 42 | SDL_BLENDMODE_NONE = 0x00000000, /**< no blending 43 | dstRGBA = srcRGBA */ 44 | SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending 45 | dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) 46 | dstA = srcA + (dstA * (1-srcA)) */ 47 | SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending 48 | dstRGB = (srcRGB * srcA) + dstRGB 49 | dstA = dstA */ 50 | SDL_BLENDMODE_MOD = 0x00000004 /**< color modulate 51 | dstRGB = srcRGB * dstRGB 52 | dstA = dstA */ 53 | } SDL_BlendMode; 54 | 55 | /* Ends C function definitions when using C++ */ 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | #include "close_code.h" 60 | 61 | #endif /* _SDL_blendmode_h */ 62 | 63 | /* vi: set ts=4 sw=4 expandtab: */ 64 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_clipboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_clipboard.h 24 | * 25 | * Include file for SDL clipboard handling 26 | */ 27 | 28 | #ifndef _SDL_clipboard_h 29 | #define _SDL_clipboard_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* Function prototypes */ 40 | 41 | /** 42 | * \brief Put UTF-8 text into the clipboard 43 | * 44 | * \sa SDL_GetClipboardText() 45 | */ 46 | extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); 47 | 48 | /** 49 | * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() 50 | * 51 | * \sa SDL_SetClipboardText() 52 | */ 53 | extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); 54 | 55 | /** 56 | * \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty 57 | * 58 | * \sa SDL_GetClipboardText() 59 | */ 60 | extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); 61 | 62 | 63 | /* Ends C function definitions when using C++ */ 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #include "close_code.h" 68 | 69 | #endif /* _SDL_clipboard_h */ 70 | 71 | /* vi: set ts=4 sw=4 expandtab: */ 72 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_error.h 24 | * 25 | * Simple error message routines for SDL. 26 | */ 27 | 28 | #ifndef _SDL_error_h 29 | #define _SDL_error_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* Public functions */ 40 | /* SDL_SetError() unconditionally returns -1. */ 41 | extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 42 | extern DECLSPEC const char *SDLCALL SDL_GetError(void); 43 | extern DECLSPEC void SDLCALL SDL_ClearError(void); 44 | 45 | /** 46 | * \name Internal error functions 47 | * 48 | * \internal 49 | * Private error reporting function - used internally. 50 | */ 51 | /* @{ */ 52 | #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) 53 | #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) 54 | #define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) 55 | typedef enum 56 | { 57 | SDL_ENOMEM, 58 | SDL_EFREAD, 59 | SDL_EFWRITE, 60 | SDL_EFSEEK, 61 | SDL_UNSUPPORTED, 62 | SDL_LASTERROR 63 | } SDL_errorcode; 64 | /* SDL_Error() unconditionally returns -1. */ 65 | extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code); 66 | /* @} *//* Internal error functions */ 67 | 68 | /* Ends C function definitions when using C++ */ 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | #include "close_code.h" 73 | 74 | #endif /* _SDL_error_h */ 75 | 76 | /* vi: set ts=4 sw=4 expandtab: */ 77 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_gesture.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_gesture.h 24 | * 25 | * Include file for SDL gesture event handling. 26 | */ 27 | 28 | #ifndef _SDL_gesture_h 29 | #define _SDL_gesture_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | 35 | #include "SDL_touch.h" 36 | 37 | 38 | #include "begin_code.h" 39 | /* Set up for C function definitions, even when using C++ */ 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | typedef Sint64 SDL_GestureID; 45 | 46 | /* Function prototypes */ 47 | 48 | /** 49 | * \brief Begin Recording a gesture on the specified touch, or all touches (-1) 50 | * 51 | * 52 | */ 53 | extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); 54 | 55 | 56 | /** 57 | * \brief Save all currently loaded Dollar Gesture templates 58 | * 59 | * 60 | */ 61 | extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst); 62 | 63 | /** 64 | * \brief Save a currently loaded Dollar Gesture template 65 | * 66 | * 67 | */ 68 | extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst); 69 | 70 | 71 | /** 72 | * \brief Load Dollar Gesture templates from a file 73 | * 74 | * 75 | */ 76 | extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); 77 | 78 | 79 | /* Ends C function definitions when using C++ */ 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | #include "close_code.h" 84 | 85 | #endif /* _SDL_gesture_h */ 86 | 87 | /* vi: set ts=4 sw=4 expandtab: */ 88 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDLname_h_ 23 | #define _SDLname_h_ 24 | 25 | #if defined(__STDC__) || defined(__cplusplus) 26 | #define NeedFunctionPrototypes 1 27 | #endif 28 | 29 | #define SDL_NAME(X) SDL_##X 30 | 31 | #endif /* _SDLname_h_ */ 32 | 33 | /* vi: set ts=4 sw=4 expandtab: */ 34 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_opengles.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_opengles.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 1.X API headers. 26 | */ 27 | 28 | #ifdef __IPHONEOS__ 29 | #include 30 | #include 31 | #else 32 | #include 33 | #include 34 | #endif 35 | 36 | #ifndef APIENTRY 37 | #define APIENTRY 38 | #endif 39 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_opengles2.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_opengles2.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. 26 | */ 27 | #ifndef _MSC_VER 28 | 29 | #ifdef __IPHONEOS__ 30 | #include 31 | #include 32 | #else 33 | #include 34 | #include 35 | #include 36 | #endif 37 | 38 | #else /* _MSC_VER */ 39 | 40 | /* OpenGL ES2 headers for Visual Studio */ 41 | #include "SDL_opengles2_khrplatform.h" 42 | #include "SDL_opengles2_gl2platform.h" 43 | #include "SDL_opengles2_gl2.h" 44 | #include "SDL_opengles2_gl2ext.h" 45 | 46 | #endif /* _MSC_VER */ 47 | 48 | #ifndef APIENTRY 49 | #define APIENTRY GL_APIENTRY 50 | #endif 51 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_opengles2_gl2platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __gl2platform_h_ 2 | #define __gl2platform_h_ 3 | 4 | /* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */ 5 | 6 | /* 7 | * This document is licensed under the SGI Free Software B License Version 8 | * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . 9 | */ 10 | 11 | /* Platform-specific types and definitions for OpenGL ES 2.X gl2.h 12 | * 13 | * Adopters may modify khrplatform.h and this file to suit their platform. 14 | * You are encouraged to submit all modifications to the Khronos group so that 15 | * they can be included in future versions of this file. Please submit changes 16 | * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) 17 | * by filing a bug against product "OpenGL-ES" component "Registry". 18 | */ 19 | 20 | /*#include */ 21 | 22 | #ifndef GL_APICALL 23 | #define GL_APICALL KHRONOS_APICALL 24 | #endif 25 | 26 | #ifndef GL_APIENTRY 27 | #define GL_APIENTRY KHRONOS_APIENTRY 28 | #endif 29 | 30 | #endif /* __gl2platform_h_ */ 31 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_power.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_power_h 23 | #define _SDL_power_h 24 | 25 | /** 26 | * \file SDL_power.h 27 | * 28 | * Header for the SDL power management routines. 29 | */ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \brief The basic state for the system's power supply. 41 | */ 42 | typedef enum 43 | { 44 | SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ 45 | SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ 46 | SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ 47 | SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ 48 | SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ 49 | } SDL_PowerState; 50 | 51 | 52 | /** 53 | * \brief Get the current power supply details. 54 | * 55 | * \param secs Seconds of battery life left. You can pass a NULL here if 56 | * you don't care. Will return -1 if we can't determine a 57 | * value, or we're not running on a battery. 58 | * 59 | * \param pct Percentage of battery life left, between 0 and 100. You can 60 | * pass a NULL here if you don't care. Will return -1 if we 61 | * can't determine a value, or we're not running on a battery. 62 | * 63 | * \return The state of the battery (if any). 64 | */ 65 | extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); 66 | 67 | /* Ends C function definitions when using C++ */ 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | #include "close_code.h" 72 | 73 | #endif /* _SDL_power_h */ 74 | 75 | /* vi: set ts=4 sw=4 expandtab: */ 76 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_quit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_quit.h 24 | * 25 | * Include file for SDL quit event handling. 26 | */ 27 | 28 | #ifndef _SDL_quit_h 29 | #define _SDL_quit_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | /** 35 | * \file SDL_quit.h 36 | * 37 | * An ::SDL_QUIT event is generated when the user tries to close the application 38 | * window. If it is ignored or filtered out, the window will remain open. 39 | * If it is not ignored or filtered, it is queued normally and the window 40 | * is allowed to close. When the window is closed, screen updates will 41 | * complete, but have no effect. 42 | * 43 | * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) 44 | * and SIGTERM (system termination request), if handlers do not already 45 | * exist, that generate ::SDL_QUIT events as well. There is no way 46 | * to determine the cause of an ::SDL_QUIT event, but setting a signal 47 | * handler in your application will override the default generation of 48 | * quit events for that signal. 49 | * 50 | * \sa SDL_Quit() 51 | */ 52 | 53 | /* There are no functions directly affecting the quit event */ 54 | 55 | #define SDL_QuitRequested() \ 56 | (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0)) 57 | 58 | #endif /* _SDL_quit_h */ 59 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_revision.h: -------------------------------------------------------------------------------- 1 | #define SDL_REVISION "hg-10001:e12c38730512" 2 | #define SDL_REVISION_NUMBER 10001 3 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef _SDL_test_h 31 | #define _SDL_test_h 32 | 33 | #include "SDL.h" 34 | #include "SDL_test_common.h" 35 | #include "SDL_test_font.h" 36 | #include "SDL_test_random.h" 37 | #include "SDL_test_fuzzer.h" 38 | #include "SDL_test_crc32.h" 39 | #include "SDL_test_md5.h" 40 | #include "SDL_test_log.h" 41 | #include "SDL_test_assert.h" 42 | #include "SDL_test_harness.h" 43 | #include "SDL_test_images.h" 44 | #include "SDL_test_compare.h" 45 | 46 | #include "begin_code.h" 47 | /* Set up for C function definitions, even when using C++ */ 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | /* Global definitions */ 53 | 54 | /* 55 | * Note: Maximum size of SDLTest log message is less than SDL's limit 56 | * to ensure we can fit additional information such as the timestamp. 57 | */ 58 | #define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 59 | 60 | /* Ends C function definitions when using C++ */ 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | #include "close_code.h" 65 | 66 | #endif /* _SDL_test_h */ 67 | 68 | /* vi: set ts=4 sw=4 expandtab: */ 69 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_test_compare.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_compare.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Defines comparison functions (i.e. for surfaces). 33 | 34 | */ 35 | 36 | #ifndef _SDL_test_compare_h 37 | #define _SDL_test_compare_h 38 | 39 | #include "SDL.h" 40 | 41 | #include "SDL_test_images.h" 42 | 43 | #include "begin_code.h" 44 | /* Set up for C function definitions, even when using C++ */ 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /** 50 | * \brief Compares a surface and with reference image data for equality 51 | * 52 | * \param surface Surface used in comparison 53 | * \param referenceSurface Test Surface used in comparison 54 | * \param allowable_error Allowable difference (=sum of squared difference for each RGB component) in blending accuracy. 55 | * 56 | * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. 57 | */ 58 | int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); 59 | 60 | 61 | /* Ends C function definitions when using C++ */ 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #include "close_code.h" 66 | 67 | #endif /* _SDL_test_compare_h */ 68 | 69 | /* vi: set ts=4 sw=4 expandtab: */ 70 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_test_font.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_font.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef _SDL_test_font_h 31 | #define _SDL_test_font_h 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* Function prototypes */ 40 | 41 | #define FONT_CHARACTER_SIZE 8 42 | 43 | /** 44 | * \brief Draw a string in the currently set font. 45 | * 46 | * \param renderer The renderer to draw on. 47 | * \param x The X coordinate of the upper left corner of the character. 48 | * \param y The Y coordinate of the upper left corner of the character. 49 | * \param c The character to draw. 50 | * 51 | * \returns Returns 0 on success, -1 on failure. 52 | */ 53 | int SDLTest_DrawCharacter( SDL_Renderer *renderer, int x, int y, char c ); 54 | 55 | /** 56 | * \brief Draw a string in the currently set font. 57 | * 58 | * \param renderer The renderer to draw on. 59 | * \param x The X coordinate of the upper left corner of the string. 60 | * \param y The Y coordinate of the upper left corner of the string. 61 | * \param s The string to draw. 62 | * 63 | * \returns Returns 0 on success, -1 on failure. 64 | */ 65 | int SDLTest_DrawString( SDL_Renderer * renderer, int x, int y, const char *s ); 66 | 67 | 68 | /* Ends C function definitions when using C++ */ 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | #include "close_code.h" 73 | 74 | #endif /* _SDL_test_font_h */ 75 | 76 | /* vi: set ts=4 sw=4 expandtab: */ 77 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_test_images.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_images.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Defines some images for tests. 33 | 34 | */ 35 | 36 | #ifndef _SDL_test_images_h 37 | #define _SDL_test_images_h 38 | 39 | #include "SDL.h" 40 | 41 | #include "begin_code.h" 42 | /* Set up for C function definitions, even when using C++ */ 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /** 48 | *Type for test images. 49 | */ 50 | typedef struct SDLTest_SurfaceImage_s { 51 | int width; 52 | int height; 53 | unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ 54 | const char *pixel_data; 55 | } SDLTest_SurfaceImage_t; 56 | 57 | /* Test images */ 58 | SDL_Surface *SDLTest_ImageBlit(); 59 | SDL_Surface *SDLTest_ImageBlitColor(); 60 | SDL_Surface *SDLTest_ImageBlitAlpha(); 61 | SDL_Surface *SDLTest_ImageBlitBlendAdd(); 62 | SDL_Surface *SDLTest_ImageBlitBlend(); 63 | SDL_Surface *SDLTest_ImageBlitBlendMod(); 64 | SDL_Surface *SDLTest_ImageBlitBlendNone(); 65 | SDL_Surface *SDLTest_ImageBlitBlendAll(); 66 | SDL_Surface *SDLTest_ImageFace(); 67 | SDL_Surface *SDLTest_ImagePrimitives(); 68 | SDL_Surface *SDLTest_ImagePrimitivesBlend(); 69 | 70 | /* Ends C function definitions when using C++ */ 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | #include "close_code.h" 75 | 76 | #endif /* _SDL_test_images_h */ 77 | 78 | /* vi: set ts=4 sw=4 expandtab: */ 79 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_test_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_log.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | * 32 | * Wrapper to log in the TEST category 33 | * 34 | */ 35 | 36 | #ifndef _SDL_test_log_h 37 | #define _SDL_test_log_h 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /** 46 | * \brief Prints given message with a timestamp in the TEST category and INFO priority. 47 | * 48 | * \param fmt Message to be logged 49 | */ 50 | void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 51 | 52 | /** 53 | * \brief Prints given message with a timestamp in the TEST category and the ERROR priority. 54 | * 55 | * \param fmt Message to be logged 56 | */ 57 | void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 58 | 59 | /* Ends C function definitions when using C++ */ 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | #include "close_code.h" 64 | 65 | #endif /* _SDL_test_log_h */ 66 | 67 | /* vi: set ts=4 sw=4 expandtab: */ 68 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_touch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_touch.h 24 | * 25 | * Include file for SDL touch event handling. 26 | */ 27 | 28 | #ifndef _SDL_touch_h 29 | #define _SDL_touch_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | 35 | #include "begin_code.h" 36 | /* Set up for C function definitions, even when using C++ */ 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef Sint64 SDL_TouchID; 42 | typedef Sint64 SDL_FingerID; 43 | 44 | typedef struct SDL_Finger 45 | { 46 | SDL_FingerID id; 47 | float x; 48 | float y; 49 | float pressure; 50 | } SDL_Finger; 51 | 52 | /* Used as the device ID for mouse events simulated with touch input */ 53 | #define SDL_TOUCH_MOUSEID ((Uint32)-1) 54 | 55 | 56 | /* Function prototypes */ 57 | 58 | /** 59 | * \brief Get the number of registered touch devices. 60 | */ 61 | extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); 62 | 63 | /** 64 | * \brief Get the touch ID with the given index, or 0 if the index is invalid. 65 | */ 66 | extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); 67 | 68 | /** 69 | * \brief Get the number of active fingers for a given touch device. 70 | */ 71 | extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID); 72 | 73 | /** 74 | * \brief Get the finger object of the given touch, with the given index. 75 | */ 76 | extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index); 77 | 78 | /* Ends C function definitions when using C++ */ 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | #include "close_code.h" 83 | 84 | #endif /* _SDL_touch_h */ 85 | 86 | /* vi: set ts=4 sw=4 expandtab: */ 87 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/SDL_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_types.h 24 | * 25 | * \deprecated 26 | */ 27 | 28 | /* DEPRECATED */ 29 | #include "SDL_stdinc.h" 30 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/include/close_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file close_code.h 24 | * 25 | * This file reverses the effects of begin_code.h and should be included 26 | * after you finish any function and structure declarations in your headers 27 | */ 28 | 29 | #undef _begin_code_h 30 | 31 | /* Reset structure packing at previous byte alignment */ 32 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) 33 | #ifdef __BORLANDC__ 34 | #pragma nopackwarning 35 | #endif 36 | #pragma pack(pop) 37 | #endif /* Compiler needs structure packing set */ 38 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/libx86/SDL2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Motor2D/SDL/libx86/SDL2.lib -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL/libx86/SDL2main.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Motor2D/SDL/libx86/SDL2main.lib -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL_image/COPYING.txt: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_image: An example image loading library for use with SDL 3 | Copyright (C) 1997-2013 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL_image/README.txt: -------------------------------------------------------------------------------- 1 | 2 | SDL_image 2.0 3 | 4 | The latest version of this library is available from: 5 | http://www.libsdl.org/projects/SDL_image/ 6 | 7 | This is a simple library to load images of various formats as SDL surfaces. 8 | This library supports BMP, PNM (PPM/PGM/PBM), XPM, LBM, PCX, GIF, JPEG, PNG, 9 | TGA, and TIFF formats. 10 | 11 | API: 12 | #include "SDL_image.h" 13 | 14 | SDL_Surface *IMG_Load(const char *file); 15 | or 16 | SDL_Surface *IMG_Load_RW(SDL_RWops *src, int freesrc); 17 | or 18 | SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, char *type); 19 | 20 | where type is a string specifying the format (i.e. "PNG" or "pcx"). 21 | Note that IMG_Load_RW cannot load TGA images. 22 | 23 | To create a surface from an XPM image included in C source, use: 24 | 25 | SDL_Surface *IMG_ReadXPMFromArray(char **xpm); 26 | 27 | An example program 'showimage' is included, with source in showimage.c 28 | 29 | JPEG support requires the JPEG library: http://www.ijg.org/ 30 | PNG support requires the PNG library: http://www.libpng.org/pub/png/libpng.html 31 | and the Zlib library: http://www.gzip.org/zlib/ 32 | TIFF support requires the TIFF library: ftp://ftp.sgi.com/graphics/tiff/ 33 | 34 | If you have these libraries installed in non-standard places, you can 35 | try adding those paths to the configure script, e.g. 36 | sh ./configure CPPFLAGS="-I/somewhere/include" LDFLAGS="-L/somewhere/lib" 37 | If this works, you may need to add /somewhere/lib to your LD_LIBRARY_PATH 38 | so shared library loading works correctly. 39 | 40 | This library is under the zlib License, see the file "COPYING.txt" for details. 41 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL_image/libx86/SDL2_image.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Motor2D/SDL_image/libx86/SDL2_image.lib -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL_mixer/COPYING.txt: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2013 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL_mixer/README.txt: -------------------------------------------------------------------------------- 1 | 2 | SDL_mixer 2.0 3 | 4 | The latest version of this library is available from: 5 | http://www.libsdl.org/projects/SDL_mixer/ 6 | 7 | Due to popular demand, here is a simple multi-channel audio mixer. 8 | It supports 8 channels of 16 bit stereo audio, plus a single channel 9 | of music, mixed by the popular MikMod MOD, Timidity MIDI and SMPEG MP3 10 | libraries. 11 | 12 | See the header file SDL_mixer.h and the examples playwave.c and playmus.c 13 | for documentation on this mixer library. 14 | 15 | The mixer can currently load Microsoft WAVE files and Creative Labs VOC 16 | files as audio samples, and can load MIDI files via Timidity and the 17 | following music formats via MikMod: .MOD .S3M .IT .XM. It can load 18 | Ogg Vorbis streams as music if built with Ogg Vorbis or Tremor libraries, 19 | and finally it can load MP3 music using the SMPEG or libmad libraries. 20 | 21 | Tremor decoding is disabled by default; you can enable it by passing 22 | --enable-music-ogg-tremor 23 | to configure, or by defining OGG_MUSIC and OGG_USE_TREMOR. 24 | 25 | libmad decoding is disabled by default; you can enable it by passing 26 | --enable-music-mp3-mad 27 | to configure, or by defining MP3_MAD_MUSIC 28 | vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv 29 | WARNING: The license for libmad is GPL, which means that in order to 30 | use it your application must also be GPL! 31 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | 33 | The process of mixing MIDI files to wave output is very CPU intensive, 34 | so if playing regular WAVE files sound great, but playing MIDI files 35 | sound choppy, try using 8-bit audio, mono audio, or lower frequencies. 36 | 37 | To play MIDI files, you'll need to get a complete set of GUS patches 38 | from: 39 | http://www.libsdl.org/projects/mixer/timidity/timidity.tar.gz 40 | and unpack them in /usr/local/lib under UNIX, and C:\ under Win32. 41 | 42 | This library is under the zlib license, see the file "COPYING.txt" for details. 43 | 44 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/SDL_mixer/libx86/SDL2_mixer.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Motor2D/SDL_mixer/libx86/SDL2_mixer.lib -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1App.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1APP_H__ 2 | #define __j1APP_H__ 3 | 4 | #include 5 | #include 6 | #include "j1Module.h" 7 | #include "j1PerfTimer.h" 8 | #include "j1Timer.h" 9 | #include "PugiXml\src\pugixml.hpp" 10 | 11 | // Modules 12 | class j1Window; 13 | class j1Input; 14 | class j1Render; 15 | class j1Textures; 16 | class j1ParticleSystem; 17 | class j1Scene; 18 | 19 | 20 | class j1App 21 | { 22 | public: 23 | 24 | // Constructor 25 | j1App(int argc, char* args[]); 26 | 27 | // Destructor 28 | virtual ~j1App(); 29 | 30 | // Called before render is available 31 | bool Awake(); 32 | 33 | // Called before the first frame 34 | bool Start(); 35 | 36 | // Called each loop iteration 37 | bool Update(); 38 | 39 | // Called before quitting 40 | bool CleanUp(); 41 | 42 | // Add a new module to handle 43 | void AddModule(j1Module* module); 44 | 45 | // Exposing some properties for reading 46 | int GetArgc() const; 47 | const char* GetArgv(int index) const; 48 | const char* GetTitle() const; 49 | const char* GetOrganization() const; 50 | 51 | pugi::xml_node j1App::LoadEmitters(pugi::xml_document& psystem_file) const; 52 | 53 | 54 | private: 55 | 56 | // Load config file 57 | pugi::xml_node LoadConfig(pugi::xml_document&) const; 58 | 59 | // Call modules before each loop iteration 60 | void PrepareUpdate(); 61 | 62 | // Call modules before each loop iteration 63 | void FinishUpdate(); 64 | 65 | // Call modules before each loop iteration 66 | bool PreUpdate(); 67 | 68 | // Call modules on each loop iteration 69 | bool DoUpdate(); 70 | 71 | // Call modules after each loop iteration 72 | bool PostUpdate(); 73 | 74 | public: 75 | 76 | // Modules 77 | j1Window* win = nullptr; 78 | j1Input* input = nullptr; 79 | j1Render* render = nullptr; 80 | j1Textures* tex = nullptr; 81 | j1ParticleSystem* psystem = nullptr; 82 | j1Scene* scene = nullptr; 83 | 84 | 85 | private: 86 | 87 | std::list modules; 88 | int argc; 89 | char** args; 90 | 91 | std::string title; 92 | std::string organization; 93 | 94 | j1PerfTimer ptimer; 95 | uint64 frame_count = 0; 96 | j1Timer startup_time; 97 | j1Timer frame_time; 98 | j1Timer last_sec_frame_time; 99 | uint32 last_sec_frame_count = 0; 100 | uint32 prev_last_sec_frame_count = 0; 101 | float dt = 0.0f; 102 | int capped_ms = -1; 103 | 104 | }; 105 | 106 | extern j1App* App; 107 | 108 | #endif -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1Input.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1INPUT_H__ 2 | #define __j1INPUT_H__ 3 | 4 | #include "j1Module.h" 5 | 6 | //#define NUM_KEYS 352 7 | #define NUM_MOUSE_BUTTONS 5 8 | //#define LAST_KEYS_PRESSED_BUFFER 50 9 | 10 | struct SDL_Rect; 11 | 12 | enum j1EventWindow 13 | { 14 | WE_QUIT = 0, 15 | WE_HIDE = 1, 16 | WE_SHOW = 2, 17 | WE_COUNT 18 | }; 19 | 20 | enum j1KeyState 21 | { 22 | KEY_IDLE = 0, 23 | KEY_DOWN, 24 | KEY_REPEAT, 25 | KEY_UP 26 | }; 27 | 28 | class j1Input : public j1Module 29 | { 30 | 31 | public: 32 | 33 | j1Input(); 34 | 35 | // Destructor 36 | virtual ~j1Input(); 37 | 38 | // Called before render is available 39 | bool Awake(pugi::xml_node&); 40 | 41 | // Called before the first frame 42 | bool Start(); 43 | 44 | // Called each loop iteration 45 | bool PreUpdate(); 46 | 47 | // Called before quitting 48 | bool CleanUp(); 49 | 50 | // Gather relevant win events 51 | bool GetWindowEvent(j1EventWindow ev); 52 | 53 | // Check key states (includes mouse and joy buttons) 54 | j1KeyState GetKey(int id) const 55 | { 56 | return keyboard[id]; 57 | } 58 | 59 | j1KeyState GetMouseButtonDown(int id) const 60 | { 61 | return mouse_buttons[id - 1]; 62 | } 63 | 64 | // Check if a certain window event happened 65 | bool GetWindowEvent(int code); 66 | 67 | // Get mouse / axis position 68 | void GetMousePosition(int &x, int &y); 69 | void GetMouseMotion(int& x, int& y); 70 | 71 | private: 72 | bool windowEvents[WE_COUNT]; 73 | j1KeyState* keyboard; 74 | j1KeyState mouse_buttons[NUM_MOUSE_BUTTONS]; 75 | int mouse_motion_x; 76 | int mouse_motion_y; 77 | int mouse_x; 78 | int mouse_y; 79 | }; 80 | 81 | #endif // __j1INPUT_H__ -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "p2Defs.h" 4 | #include "p2Log.h" 5 | #include "j1App.h" 6 | 7 | // This is needed here because SDL redefines main function 8 | // do not add any other libraries here, instead put them in their modules 9 | #include "SDL/include/SDL.h" 10 | #pragma comment( lib, "SDL/libx86/SDL2.lib" ) 11 | #pragma comment( lib, "SDL/libx86/SDL2main.lib" ) 12 | 13 | enum MainState 14 | { 15 | CREATE = 1, 16 | AWAKE, 17 | START, 18 | LOOP, 19 | CLEAN, 20 | FAIL, 21 | EXIT 22 | }; 23 | 24 | j1App* App = NULL; 25 | 26 | int main(int argc, char* args[]) 27 | { 28 | LOG("Engine starting ... %d"); 29 | 30 | MainState state = MainState::CREATE; 31 | int result = EXIT_FAILURE; 32 | 33 | while(state != EXIT) 34 | { 35 | switch(state) 36 | { 37 | 38 | // Allocate the engine -------------------------------------------- 39 | case CREATE: 40 | LOG("CREATION PHASE ==============================="); 41 | 42 | App = new j1App(argc, args); 43 | 44 | if(App != NULL) 45 | state = AWAKE; 46 | else 47 | state = FAIL; 48 | 49 | break; 50 | 51 | // Awake all modules ----------------------------------------------- 52 | case AWAKE: 53 | LOG("AWAKE PHASE ==============================="); 54 | if(App->Awake() == true) 55 | state = START; 56 | else 57 | { 58 | LOG("ERROR: Awake failed"); 59 | state = FAIL; 60 | } 61 | 62 | break; 63 | 64 | // Call all modules before first frame ---------------------------- 65 | case START: 66 | LOG("START PHASE ==============================="); 67 | if(App->Start() == true) 68 | { 69 | state = LOOP; 70 | LOG("UPDATE PHASE ==============================="); 71 | } 72 | else 73 | { 74 | state = FAIL; 75 | LOG("ERROR: Start failed"); 76 | } 77 | break; 78 | 79 | // Loop all modules until we are asked to leave --------------------- 80 | case LOOP: 81 | if(App->Update() == false) 82 | state = CLEAN; 83 | break; 84 | 85 | // Cleanup allocated memory ----------------------------------------- 86 | case CLEAN: 87 | LOG("CLEANUP PHASE ==============================="); 88 | if(App->CleanUp() == true) 89 | { 90 | RELEASE(App); 91 | result = EXIT_SUCCESS; 92 | state = EXIT; 93 | } 94 | else 95 | state = FAIL; 96 | 97 | break; 98 | 99 | // Exit with errors and shame --------------------------------------- 100 | case FAIL: 101 | LOG("Exiting with errors :("); 102 | result = EXIT_FAILURE; 103 | state = EXIT; 104 | break; 105 | } 106 | } 107 | 108 | LOG("... Bye! :)\n"); 109 | 110 | // Dump memory leaks 111 | return result; 112 | } -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1Module.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------- 2 | // j1Module.h 3 | // Interface for all engine modules 4 | // ---------------------------------------------------- 5 | 6 | #ifndef __j1MODULE_H__ 7 | #define __j1MODULE_H__ 8 | 9 | #include 10 | #include "PugiXml\src\pugixml.hpp" 11 | 12 | class j1App; 13 | 14 | class j1Module 15 | { 16 | public: 17 | 18 | j1Module() : active(false) 19 | {} 20 | 21 | void Init() 22 | { 23 | active = true; 24 | } 25 | 26 | // Called before render is available 27 | virtual bool Awake(pugi::xml_node&) 28 | { 29 | return true; 30 | } 31 | 32 | // Called before the first frame 33 | virtual bool Start() 34 | { 35 | return true; 36 | } 37 | 38 | // Called each loop iteration 39 | virtual bool PreUpdate() 40 | { 41 | return true; 42 | } 43 | 44 | // Called each loop iteration 45 | virtual bool Update(float dt) 46 | { 47 | return true; 48 | } 49 | 50 | // Called each loop iteration 51 | virtual bool PostUpdate() 52 | { 53 | return true; 54 | } 55 | 56 | // Called before quitting 57 | virtual bool CleanUp() 58 | { 59 | return true; 60 | } 61 | 62 | virtual bool Load(pugi::xml_node&) 63 | { 64 | return true; 65 | } 66 | 67 | virtual bool Save(pugi::xml_node&) const 68 | { 69 | return true; 70 | } 71 | 72 | public: 73 | 74 | std::string name; 75 | bool active; 76 | 77 | }; 78 | 79 | #endif // __j1MODULE_H__ -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1ParticleSystem.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/exercices/2D Particle System/Motor2D/j1ParticleSystem.cpp -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1ParticleSystem.h: -------------------------------------------------------------------------------- 1 | #ifndef __J1_PARTICLE_SYSTEM_H__ 2 | #define __J1_PARTICLE_SYSTEM_H__ 3 | 4 | #include "p2Point.h" 5 | #include "j1Module.h" 6 | #include "Emitter.h" 7 | #include 8 | #include 9 | #include "SDL/include/SDL.h" 10 | 11 | #define MAX_NUM_EMITTERS_TYPE 1 12 | 13 | class Emitter; 14 | struct SDL_Texture; 15 | struct SDL_Rect; 16 | struct SDL_Color; 17 | 18 | enum EmitterType 19 | { 20 | EMITTER_TYPE_NONE = -1, 21 | EMITTER_TYPE_FIRE 22 | }; 23 | 24 | struct EmitterData 25 | { 26 | fPoint angleRange = { 0.0f, 0.0f }; 27 | float startSpeed = 0.0f, endSpeed = 0.0f; 28 | float startSize = 0.0f, endSize = 0.0f; 29 | uint emitNumber = 0u; 30 | uint emitVariance = 0u; 31 | uint maxParticleLife = 0u; 32 | SDL_Rect textureRect = { 0, 0 }; 33 | double lifetime = -1.0f; 34 | SDL_Color startColor = { 0, 0, 0, 0 }; 35 | SDL_Color endColor = { 0, 0, 0, 0 }; 36 | SDL_BlendMode blendMode = SDL_BlendMode::SDL_BLENDMODE_NONE; 37 | double rotSpeed = 0; 38 | 39 | // Randoms 40 | fPoint rotSpeedRand = { 0.0f, 0.0f }; 41 | fPoint startSpeedRand = { 0.0f, 0.0f }; 42 | fPoint endSpeedRand = { 0.0f, 0.0f }; 43 | fPoint emitVarianceRand = { 0.0f, 0.0f }; 44 | fPoint lifeRand = { 0.0f, 0.0f }; 45 | fPoint startSizeRand = { 0.0f, 0.0f }; 46 | fPoint endSizeRand = { 0.0f, 0.0f }; 47 | }; 48 | 49 | class j1ParticleSystem : public j1Module 50 | { 51 | 52 | private: 53 | 54 | std::list emittersList; 55 | SDL_Texture* particleAtlas = nullptr; 56 | std::string nameParticleAtlas; 57 | 58 | // Static array that stores all the data of emitters 59 | EmitterData vecEmitterData[MAX_NUM_EMITTERS_TYPE]; 60 | 61 | public: 62 | 63 | j1ParticleSystem(); 64 | 65 | // Destructor 66 | virtual ~j1ParticleSystem(); 67 | 68 | // Called when before render is available 69 | bool Awake(pugi::xml_node& config); 70 | 71 | // Call before first frame 72 | bool Start(); 73 | 74 | // Called before all Updates 75 | bool PreUpdate(); 76 | 77 | // Called each loop iteration 78 | bool Update(float dt); 79 | 80 | // Called after all Updates 81 | bool PostUpdate(); 82 | 83 | // Called before quitting 84 | bool CleanUp(); 85 | 86 | // Emitter methods 87 | Emitter* AddEmiter(fPoint pos, EmitterType type); 88 | bool RemoveEmitter(Emitter& emitter); 89 | bool RemoveAllEmitters(); 90 | 91 | SDL_Texture* GetParticleAtlas() const; 92 | void LoadEmitterData(pugi::xml_node& config, EmitterType type); 93 | }; 94 | 95 | #endif -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1PerfTimer.cpp: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------- 2 | // j1PerfTimer.cpp 3 | // Slow timer with microsecond precision 4 | // ---------------------------------------------------- 5 | 6 | #include "j1PerfTimer.h" 7 | #include "SDL\include\SDL_timer.h" 8 | 9 | uint64 j1PerfTimer::frequency = 0; 10 | 11 | // --------------------------------------------- 12 | j1PerfTimer::j1PerfTimer() 13 | { 14 | if (frequency == 0) 15 | frequency = SDL_GetPerformanceFrequency(); 16 | 17 | Start(); 18 | } 19 | 20 | // --------------------------------------------- 21 | void j1PerfTimer::Start() 22 | { 23 | started_at = SDL_GetPerformanceCounter(); 24 | } 25 | 26 | // --------------------------------------------- 27 | double j1PerfTimer::ReadMs() const 28 | { 29 | return 1000.0 * (double(SDL_GetPerformanceCounter() - started_at) / double(frequency)); 30 | } 31 | 32 | // --------------------------------------------- 33 | uint64 j1PerfTimer::ReadTicks() const 34 | { 35 | return SDL_GetPerformanceCounter() - started_at; 36 | } -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1PerfTimer.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1PERFTIMER_H__ 2 | #define __j1PERFTIMER_H__ 3 | 4 | #include "p2Defs.h" 5 | 6 | class j1PerfTimer 7 | { 8 | public: 9 | 10 | // Constructor 11 | j1PerfTimer(); 12 | 13 | void Start(); 14 | double ReadMs() const; 15 | uint64 ReadTicks() const; 16 | 17 | private: 18 | uint64 started_at; 19 | static uint64 frequency; 20 | }; 21 | 22 | #endif //__j1PERFTIMER_H__ -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1Render.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1RENDER_H__ 2 | #define __j1RENDER_H__ 3 | 4 | #include "SDL/include/SDL.h" 5 | #include "j1Module.h" 6 | 7 | class j1Render : public j1Module 8 | { 9 | public: 10 | 11 | j1Render(); 12 | 13 | // Destructor 14 | virtual ~j1Render(); 15 | 16 | // Called before render is available 17 | bool Awake(pugi::xml_node&); 18 | 19 | // Called before the first frame 20 | bool Start(); 21 | 22 | // Called each loop iteration 23 | bool PreUpdate(); 24 | bool Update(float dt); 25 | bool PostUpdate(); 26 | 27 | // Called before quitting 28 | bool CleanUp(); 29 | 30 | // Load / Save 31 | bool Load(pugi::xml_node&); 32 | bool Save(pugi::xml_node&) const; 33 | 34 | // Blit 35 | void SetViewPort(const SDL_Rect& rect); 36 | void ResetViewPort(); 37 | 38 | bool BlitParticle(SDL_Texture* texture, int x, int y, const SDL_Rect* section = NULL, const SDL_Rect* rectSize = NULL, float speed = 1.0f, double angle = 0) const; 39 | bool Blit(SDL_Texture* texture, int x, int y, const SDL_Rect* section, float speed = 1.0f, double angle = 0, int pivot_x = INT_MAX, int pivot_y = INT_MAX) const; 40 | bool DrawQuad(const SDL_Rect& rect, Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255, bool filled = true, bool use_camera = true) const; 41 | bool DrawLine(int x1, int y1, int x2, int y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255, bool use_camera = true) const; 42 | bool DrawCircle(int x1, int y1, int redius, Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255, bool filled = false, bool use_camera = true) const; 43 | 44 | // Set background color 45 | void SetBackgroundColor(SDL_Color color); 46 | 47 | public: 48 | 49 | SDL_Renderer* renderer; 50 | SDL_Rect camera; 51 | SDL_Rect viewport; 52 | SDL_Color background; 53 | }; 54 | 55 | #endif // __j1RENDER_H__ -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1Scene.cpp: -------------------------------------------------------------------------------- 1 | #include "j1App.h" 2 | #include "j1Input.h" 3 | #include "j1Scene.h" 4 | #include "j1Render.h" 5 | #include "j1Textures.h" 6 | #include "p2Log.h" 7 | 8 | j1Scene::j1Scene() : j1Module() 9 | { 10 | name = "scene"; 11 | } 12 | 13 | // Destructor 14 | j1Scene::~j1Scene() 15 | {} 16 | 17 | // Called before render is available 18 | bool j1Scene::Awake() 19 | { 20 | LOG("Loading Scene"); 21 | bool ret = true; 22 | 23 | return ret; 24 | } 25 | 26 | // Called before the first frame 27 | bool j1Scene::Start() 28 | { 29 | torchTex = App->tex->Load("textures/torch.png"); 30 | return true; 31 | } 32 | 33 | // Called each loop iteration 34 | bool j1Scene::PreUpdate() 35 | { 36 | return true; 37 | } 38 | 39 | // Called each loop iteration 40 | bool j1Scene::Update(float dt) 41 | { 42 | if (App->input->GetMouseButtonDown(SDL_BUTTON_LEFT) == KEY_DOWN) 43 | { 44 | int mx, my; 45 | App->input->GetMousePosition(mx, my); 46 | fPoint pos((float)mx, (float)my); 47 | pos.y -= 230.0f; 48 | eFire = App->psystem->AddEmiter(pos, EmitterType::EMITTER_TYPE_FIRE); 49 | } 50 | 51 | /*TODO 5 - Tweak the xml parameters 52 | - Change the emitter data in order to get a flame. 53 | - Uncomment code in Scene update to blit the torch. 54 | - Optional: create a new one and try simulate smoke.*/ 55 | 56 | int mx, my; 57 | App->input->GetMousePosition(mx, my); 58 | fPoint pos((float)mx, (float)my); 59 | 60 | App->render->Blit(torchTex, pos.x - 43, pos.y - 270, &rect); 61 | 62 | if (eFire != nullptr) 63 | { 64 | int mx, my; 65 | App->input->GetMousePosition(mx, my); 66 | fPoint pos((float)mx, (float)my); 67 | pos.y -= 230.0f; 68 | eFire->MoveEmitter(pos); 69 | } 70 | 71 | return true; 72 | } 73 | 74 | // Called each loop iteration 75 | bool j1Scene::PostUpdate() 76 | { 77 | bool ret = true; 78 | 79 | if (App->input->GetKey(SDL_SCANCODE_ESCAPE) == KEY_DOWN) 80 | ret = false; 81 | 82 | return ret; 83 | } 84 | 85 | // Called before quitting 86 | bool j1Scene::CleanUp() 87 | { 88 | LOG("Freeing scene"); 89 | 90 | eFire = nullptr; 91 | 92 | App->tex->UnLoad(torchTex); 93 | torchTex = nullptr; 94 | 95 | return true; 96 | } -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1Scene.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1SCENE_H__ 2 | #define __j1SCENE_H__ 3 | 4 | #include "j1Module.h" 5 | #include "Particle.h" 6 | #include "ParticlePool.h" 7 | #include "Emitter.h" 8 | #include "p2Point.h" 9 | 10 | struct SDL_Texture; 11 | 12 | class j1Scene : public j1Module 13 | { 14 | public: 15 | 16 | j1Scene(); 17 | 18 | // Destructor 19 | virtual ~j1Scene(); 20 | 21 | // Called before render is available 22 | bool Awake(); 23 | 24 | // Called before the first frame 25 | bool Start(); 26 | 27 | // Called before all Updates 28 | bool PreUpdate(); 29 | 30 | // Called each loop iteration 31 | bool Update(float dt); 32 | 33 | // Called before all Updates 34 | bool PostUpdate(); 35 | 36 | // Called before quitting 37 | bool CleanUp(); 38 | 39 | private: 40 | 41 | Emitter* eFire = nullptr; 42 | SDL_Rect rect = { 0, 0, 400, 400 }; 43 | SDL_Texture* torchTex = nullptr; 44 | 45 | }; 46 | 47 | #endif // __j1SCENE_H__ -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1Textures.cpp: -------------------------------------------------------------------------------- 1 | #include "p2Defs.h" 2 | #include "p2Log.h" 3 | #include "j1App.h" 4 | #include "j1Render.h" 5 | #include "j1Textures.h" 6 | 7 | #include "SDL_image/include/SDL_image.h" 8 | #pragma comment( lib, "SDL_image/libx86/SDL2_image.lib" ) 9 | 10 | j1Textures::j1Textures() : j1Module() 11 | { 12 | name = "textures"; 13 | } 14 | 15 | // Destructor 16 | j1Textures::~j1Textures() 17 | {} 18 | 19 | // Called before render is available 20 | bool j1Textures::Awake(pugi::xml_node& config) 21 | { 22 | LOG("Init Image library"); 23 | bool ret = true; 24 | // load support for the PNG image format 25 | int flags = IMG_INIT_PNG; 26 | int init = IMG_Init(flags); 27 | 28 | if((init & flags) != flags) 29 | { 30 | LOG("Could not initialize Image lib. IMG_Init: %s", IMG_GetError()); 31 | ret = false; 32 | } 33 | 34 | return ret; 35 | } 36 | 37 | // Called before the first frame 38 | bool j1Textures::Start() 39 | { 40 | LOG("start textures"); 41 | bool ret = true; 42 | return ret; 43 | } 44 | 45 | // Called before quitting 46 | bool j1Textures::CleanUp() 47 | { 48 | LOG("Freeing textures and Image library"); 49 | std::list::const_iterator item; 50 | 51 | for (item = textures.begin(); item != textures.end(); ++item) 52 | { 53 | SDL_DestroyTexture(*item); 54 | } 55 | 56 | textures.clear(); 57 | IMG_Quit(); 58 | return true; 59 | } 60 | 61 | // Load new texture from file path 62 | SDL_Texture* const j1Textures::Load(const char* path) 63 | { 64 | SDL_Texture* texture = NULL; 65 | SDL_Surface* surface = IMG_Load(path); 66 | 67 | if(surface == NULL) 68 | { 69 | LOG("Could not load surface with path: %s. IMG_Load: %s", path, IMG_GetError()); 70 | } 71 | else 72 | { 73 | texture = LoadSurface(surface); 74 | SDL_FreeSurface(surface); 75 | } 76 | 77 | return texture; 78 | } 79 | 80 | // Unload texture 81 | bool j1Textures::UnLoad(SDL_Texture* texture) 82 | { 83 | std::list::const_iterator item; 84 | 85 | for (item = textures.begin(); item != textures.end(); item = ++item) 86 | { 87 | if (texture == *item) 88 | { 89 | SDL_DestroyTexture(*item); 90 | textures.remove(*item); 91 | return true; 92 | } 93 | } 94 | 95 | return false; 96 | } 97 | 98 | // Translate a surface into a texture 99 | SDL_Texture* const j1Textures::LoadSurface(SDL_Surface* surface) 100 | { 101 | SDL_Texture* texture = SDL_CreateTextureFromSurface(App->render->renderer, surface); 102 | 103 | if(texture == NULL) 104 | { 105 | LOG("Unable to create texture from surface! SDL Error: %s\n", SDL_GetError()); 106 | } 107 | else 108 | { 109 | textures.remove(texture); 110 | } 111 | 112 | return texture; 113 | } 114 | 115 | // Retrieve size of a texture 116 | void j1Textures::GetSize(const SDL_Texture* texture, uint& width, uint& height) const 117 | { 118 | SDL_QueryTexture((SDL_Texture*)texture, NULL, NULL, (int*) &width, (int*) &height); 119 | } 120 | -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1Textures.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1TEXTURES_H__ 2 | #define __j1TEXTURES_H__ 3 | 4 | #include "j1Module.h" 5 | #include 6 | 7 | struct SDL_Texture; 8 | struct SDL_Surface; 9 | 10 | class j1Textures : public j1Module 11 | { 12 | public: 13 | 14 | j1Textures(); 15 | 16 | // Destructor 17 | virtual ~j1Textures(); 18 | 19 | // Called before render is available 20 | bool Awake(pugi::xml_node&); 21 | 22 | // Called before the first frame 23 | bool Start(); 24 | 25 | // Called before quitting 26 | bool CleanUp(); 27 | 28 | // Load Texture 29 | SDL_Texture* const Load(const char* path); 30 | bool UnLoad(SDL_Texture* texture); 31 | SDL_Texture* const LoadSurface(SDL_Surface* surface); 32 | void GetSize(const SDL_Texture* texture, uint& width, uint& height) const; 33 | 34 | public: 35 | 36 | std::list textures; 37 | }; 38 | 39 | 40 | #endif // __j1TEXTURES_H__ -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1Timer.cpp: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------- 2 | // j1Timer.cpp 3 | // Fast timer with milisecons precision 4 | // ---------------------------------------------------- 5 | 6 | #include "j1Timer.h" 7 | #include "SDL\include\SDL_timer.h" 8 | 9 | // --------------------------------------------- 10 | j1Timer::j1Timer() 11 | { 12 | Start(); 13 | } 14 | 15 | // --------------------------------------------- 16 | void j1Timer::Start() 17 | { 18 | started_at = SDL_GetTicks(); 19 | } 20 | 21 | // --------------------------------------------- 22 | uint32 j1Timer::Read() const 23 | { 24 | return SDL_GetTicks() - started_at; 25 | } 26 | 27 | // --------------------------------------------- 28 | float j1Timer::ReadSec() const 29 | { 30 | return float(SDL_GetTicks() - started_at) / 1000.0f; 31 | } -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1Timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1TIMER_H__ 2 | #define __j1TIMER_H__ 3 | 4 | #include "p2Defs.h" 5 | 6 | class j1Timer 7 | { 8 | public: 9 | 10 | // Constructor 11 | j1Timer(); 12 | 13 | void Start(); 14 | uint32 Read() const; 15 | float ReadSec() const; 16 | 17 | private: 18 | uint32 started_at; 19 | }; 20 | 21 | #endif //__j1TIMER_H__ -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1Window.cpp: -------------------------------------------------------------------------------- 1 | #include "p2Defs.h" 2 | #include "p2Log.h" 3 | #include "j1App.h" 4 | #include "j1Window.h" 5 | 6 | #include "SDL/include/SDL.h" 7 | 8 | 9 | j1Window::j1Window() : j1Module() 10 | { 11 | window = NULL; 12 | screen_surface = NULL; 13 | name = "window"; 14 | } 15 | 16 | // Destructor 17 | j1Window::~j1Window() 18 | { 19 | } 20 | 21 | // Called before render is available 22 | bool j1Window::Awake(pugi::xml_node& config) 23 | { 24 | LOG("Init SDL window & surface"); 25 | bool ret = true; 26 | 27 | if(SDL_Init(SDL_INIT_VIDEO) < 0) 28 | { 29 | LOG("SDL_VIDEO could not initialize! SDL_Error: %s\n", SDL_GetError()); 30 | ret = false; 31 | } 32 | else 33 | { 34 | //Create window 35 | Uint32 flags = SDL_WINDOW_SHOWN; 36 | bool fullscreen = config.child("fullscreen").attribute("value").as_bool(false); 37 | bool borderless = config.child("borderless").attribute("value").as_bool(false); 38 | bool resizable = config.child("resizable").attribute("value").as_bool(false); 39 | bool fullscreen_window = config.child("fullscreen_window").attribute("value").as_bool(false); 40 | 41 | width = config.child("resolution").attribute("width").as_int(640); 42 | height = config.child("resolution").attribute("height").as_int(480); 43 | scale = config.child("resolution").attribute("scale").as_int(1); 44 | 45 | if(fullscreen == true) 46 | { 47 | flags |= SDL_WINDOW_FULLSCREEN; 48 | } 49 | 50 | if(borderless == true) 51 | { 52 | flags |= SDL_WINDOW_BORDERLESS; 53 | } 54 | 55 | if(resizable == true) 56 | { 57 | flags |= SDL_WINDOW_RESIZABLE; 58 | } 59 | 60 | if(fullscreen_window == true) 61 | { 62 | flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; 63 | } 64 | 65 | window = SDL_CreateWindow(App->GetTitle(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags); 66 | 67 | if(window == NULL) 68 | { 69 | LOG("Window could not be created! SDL_Error: %s\n", SDL_GetError()); 70 | ret = false; 71 | } 72 | else 73 | { 74 | //Get window surface 75 | screen_surface = SDL_GetWindowSurface(window); 76 | } 77 | } 78 | 79 | return ret; 80 | } 81 | 82 | // Called before quitting 83 | bool j1Window::CleanUp() 84 | { 85 | LOG("Destroying SDL window and quitting all SDL systems"); 86 | 87 | //Destroy window 88 | if(window != NULL) 89 | { 90 | SDL_DestroyWindow(window); 91 | } 92 | 93 | //Quit SDL subsystems 94 | SDL_Quit(); 95 | return true; 96 | } 97 | 98 | // Set new window title 99 | void j1Window::SetTitle(const char* new_title) 100 | { 101 | //title.create(new_title); 102 | SDL_SetWindowTitle(window, new_title); 103 | } 104 | 105 | void j1Window::GetWindowSize(uint& width, uint& height) const 106 | { 107 | width = this->width; 108 | height = this->height; 109 | } 110 | 111 | uint j1Window::GetScale() const 112 | { 113 | return scale; 114 | } -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/j1Window.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1WINDOW_H__ 2 | #define __j1WINDOW_H__ 3 | 4 | #include "j1Module.h" 5 | 6 | struct SDL_Window; 7 | struct SDL_Surface; 8 | 9 | class j1Window : public j1Module 10 | { 11 | public: 12 | 13 | j1Window(); 14 | 15 | // Destructor 16 | virtual ~j1Window(); 17 | 18 | // Called before render is available 19 | bool Awake(pugi::xml_node&); 20 | 21 | // Called before quitting 22 | bool CleanUp(); 23 | 24 | // Changae title 25 | void SetTitle(const char* new_title); 26 | 27 | // Retrive window size 28 | void GetWindowSize(uint& width, uint& height) const; 29 | 30 | // Retrieve window scale 31 | uint GetScale() const; 32 | 33 | public: 34 | //The window we'll be rendering to 35 | SDL_Window* window; 36 | 37 | //The surface contained by the window 38 | SDL_Surface* screen_surface; 39 | 40 | private: 41 | std::string title; 42 | std::string icon; 43 | 44 | // Screen parameters 45 | uint width = 0u; 46 | uint height = 0u; 47 | uint scale = 0u; 48 | }; 49 | 50 | #endif // __j1WINDOW_H__ -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/p2Defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __P2DEFS_H__ 2 | #define __P2DEFS_H__ 3 | 4 | #include 5 | 6 | // NULL just in case ---------------------- 7 | 8 | #ifdef NULL 9 | #undef NULL 10 | #endif 11 | #define NULL 0 12 | 13 | // Deletes a buffer 14 | #define RELEASE( x ) \ 15 | { \ 16 | if( x != NULL ) \ 17 | { \ 18 | delete x; \ 19 | x = NULL; \ 20 | } \ 21 | } 22 | 23 | // Deletes an array of buffers 24 | #define RELEASE_ARRAY( x ) \ 25 | { \ 26 | if( x != NULL ) \ 27 | { \ 28 | delete[] x; \ 29 | x = NULL; \ 30 | } \ 31 | \ 32 | } 33 | 34 | #define IN_RANGE( value, min, max ) ( ((value) >= (min) && (value) <= (max)) ? 1 : 0 ) 35 | #define MIN( a, b ) ( ((a) < (b)) ? (a) : (b) ) 36 | #define MAX( a, b ) ( ((a) > (b)) ? (a) : (b) ) 37 | #define TO_BOOL( a ) ( (a != 0) ? true : false ) 38 | 39 | typedef unsigned int uint; 40 | typedef unsigned __int8 uint8; 41 | typedef unsigned __int32 uint32; 42 | typedef unsigned __int64 uint64; 43 | typedef unsigned char uchar; 44 | 45 | template void SWAP(VALUE_TYPE& a, VALUE_TYPE& b) 46 | { 47 | VALUE_TYPE tmp = a; 48 | a = b; 49 | b = tmp; 50 | } 51 | 52 | // Standard string size 53 | #define SHORT_STR 32 54 | #define MID_STR 255 55 | #define HUGE_STR 8192 56 | 57 | // Joins a path and file 58 | inline const char* const PATH(const char* folder, const char* file) 59 | { 60 | static char path[MID_STR]; 61 | sprintf_s(path, MID_STR, "%s/%s", folder, file); 62 | return path; 63 | } 64 | 65 | // Performance macros 66 | #define PERF_START(timer) timer.Start() 67 | #define PERF_PEEK(timer) LOG("%s took %f ms", __FUNCTION__, timer.ReadMs()) 68 | 69 | // Maths calculations 70 | #define PI 3.14159265359f 71 | #define DEG_TO_RAD(a) a * PI / 180.0f 72 | #define RAD_TO_DEG(a) a * 180.0f / PI 73 | 74 | #endif -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/p2Log.cpp: -------------------------------------------------------------------------------- 1 | #include "p2Log.h" 2 | 3 | void log(const char file[], int line, const char* format, ...) 4 | { 5 | static char tmp_string[4096]; 6 | static char tmp_string2[4096]; 7 | static va_list ap; 8 | 9 | // Construct the string from variable arguments 10 | va_start(ap, format); 11 | vsprintf_s(tmp_string, 4096, format, ap); 12 | va_end(ap); 13 | sprintf_s(tmp_string2, 4096, "\n%s(%d) : %s", file, line, tmp_string); 14 | OutputDebugString(tmp_string2); 15 | } -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/p2Log.h: -------------------------------------------------------------------------------- 1 | #ifndef __p2Log_H__ 2 | #define __p2Log_H__ 3 | 4 | #include 5 | #include 6 | 7 | #define LOG(format, ...) log(__FILE__, __LINE__, format, __VA_ARGS__) 8 | 9 | void log(const char file[], int line, const char* format, ...); 10 | 11 | #endif -------------------------------------------------------------------------------- /exercices/2D Particle System/Motor2D/p2Point.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------- 2 | // Point class ----------- 3 | // ---------------------------------------------------- 4 | 5 | #ifndef __P2POINT_H__ 6 | #define __P2POINT_H__ 7 | 8 | #include "p2Defs.h" 9 | #include 10 | 11 | template 12 | class p2Point 13 | { 14 | public: 15 | 16 | TYPE x, y; 17 | 18 | p2Point() 19 | {} 20 | 21 | p2Point(const p2Point& v) 22 | { 23 | this->x = v.x; 24 | this->y = v.y; 25 | } 26 | 27 | p2Point(const TYPE& x, const TYPE& y) 28 | { 29 | this->x = x; 30 | this->y = y; 31 | } 32 | 33 | p2Point& create(const TYPE& x, const TYPE& y) 34 | { 35 | this->x = x; 36 | this->y = y; 37 | 38 | return(*this); 39 | } 40 | 41 | // Math ------------------------------------------------ 42 | p2Point operator -(const p2Point &v) const 43 | { 44 | p2Vector2 r; 45 | 46 | r.x = x - v.x; 47 | r.y = y - v.y; 48 | 49 | return(r); 50 | } 51 | 52 | p2Point operator + (const p2Point &v) const 53 | { 54 | p2Vector2 r; 55 | 56 | r.x = x + v.x; 57 | r.y = y + v.y; 58 | 59 | return(r); 60 | } 61 | 62 | const p2Point& operator -=(const p2Point &v) 63 | { 64 | x -= v.x; 65 | y -= v.y; 66 | 67 | return(*this); 68 | } 69 | 70 | const p2Point& operator +=(const p2Point &v) 71 | { 72 | x += v.x; 73 | y += v.y; 74 | 75 | return(*this); 76 | } 77 | 78 | bool operator ==(const p2Point& v) const 79 | { 80 | return (x == v.x && y == v.y); 81 | } 82 | 83 | bool operator !=(const p2Point& v) const 84 | { 85 | return (x != v.x || y != v.y); 86 | } 87 | 88 | // Utils ------------------------------------------------ 89 | bool IsZero() const 90 | { 91 | return (x == 0 && y == 0); 92 | } 93 | 94 | p2Point& SetToZero() 95 | { 96 | x = y = 0; 97 | return(*this); 98 | } 99 | 100 | p2Point& Negate() 101 | { 102 | x = -x; 103 | y = -y; 104 | 105 | return(*this); 106 | } 107 | 108 | // Distances --------------------------------------------- 109 | TYPE DistanceTo(const p2Point& v) const 110 | { 111 | TYPE fx = x - v.x; 112 | TYPE fy = y - v.y; 113 | 114 | return sqrtf((fx*fx) + (fy*fy)); 115 | } 116 | 117 | TYPE DistanceNoSqrt(const p2Point& v) const 118 | { 119 | TYPE fx = x - v.x; 120 | TYPE fy = y - v.y; 121 | 122 | return (fx*fx) + (fy*fy); 123 | } 124 | 125 | TYPE DistanceManhattan(const p2Point& v) const 126 | { 127 | return abs(v.x - x) + abs(v.y - y); 128 | } 129 | }; 130 | 131 | typedef p2Point iPoint; 132 | typedef p2Point fPoint; 133 | 134 | #endif // __P2POINT_H__ -------------------------------------------------------------------------------- /exercices/2D Particle System/Particle System.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2013 for Windows Desktop 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Motor 2D", "Motor2D\Motor2D.vcxproj", "{2AF9969B-F202-497B-AF30-7BEF9CE8005E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2AF9969B-F202-497B-AF30-7BEF9CE8005E}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {2AF9969B-F202-497B-AF30-7BEF9CE8005E}.Debug|Win32.Build.0 = Debug|Win32 16 | {2AF9969B-F202-497B-AF30-7BEF9CE8005E}.Release|Win32.ActiveCfg = Release|Win32 17 | {2AF9969B-F202-497B-AF30-7BEF9CE8005E}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Brofiler/Brofiler.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Brofiler/Brofiler.exe -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/ProfilerCore32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/ProfilerCore32.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/SDL2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/SDL2.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/SDL2_image.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/SDL2_image.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/SDL2_mixer.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/SDL2_mixer.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/SDL2_ttf.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/SDL2_ttf.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Particle System 6 | UPC 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/libFLAC-8.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/libFLAC-8.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/libjpeg-9.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/libjpeg-9.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/libmikmod-2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/libmikmod-2.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/libmodplug-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/libmodplug-1.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/libogg-0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/libogg-0.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/libpng16-16.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/libpng16-16.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/libtiff-5.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/libtiff-5.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/libvorbis-0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/libvorbis-0.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/libvorbisfile-3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/libvorbisfile-3.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/libwebp-4.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/libwebp-4.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/smpeg2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/smpeg2.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/textures/particles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/textures/particles.png -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/textures/torch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/textures/torch.png -------------------------------------------------------------------------------- /full_code/2D Particle System/Game/zlib1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Game/zlib1.dll -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/Brofiler/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Vadim Slyusarev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/Brofiler/ProfilerCore32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Motor2D/Brofiler/ProfilerCore32.lib -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/Brofiler/README.md: -------------------------------------------------------------------------------- 1 | # [Brofiler: C++ Profiler For Games](http://brofiler.com) 2 | Warning! This project is under extremely active development at the moment. 3 | Please use the latest [stable version](https://github.com/bombomby/brofiler/releases). 4 | 5 | ## Build status 6 | [![Build status](https://ci.appveyor.com/api/projects/status/bu5smbuh1d2lcsf6?svg=true)](https://ci.appveyor.com/project/bombomby/brofiler) 7 | 8 | ## [Tutorial](https://github.com/bombomby/brofiler/wiki) 9 | ![](http://brofiler.com/images/screenshots/Screen0.png) 10 | [![Analytics](https://ga-beacon.appspot.com/UA-59213040-1/brofiler/readme)](https://github.com/bombomby/brofiler) -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/Emitter.h: -------------------------------------------------------------------------------- 1 | #ifndef __EMITTER_H__ 2 | #define __EMITTER_H__ 3 | 4 | #include "p2Point.h" 5 | #include "j1ParticleSystem.h" 6 | #include "ParticlePool.h" 7 | #include "j1PerfTimer.h" 8 | #include "SDL/include/SDL.h" 9 | 10 | struct SDL_Texture; 11 | class ParticlePool; 12 | struct EmitterData; 13 | 14 | class Emitter 15 | { 16 | private: 17 | 18 | // Particles size and movement 19 | fPoint pos = { 0.0f, 0.0f }; 20 | fPoint angleRange = { 0.0f, 360.0f }; 21 | float startSpeed = 0.0f; 22 | float endSpeed = 0.0f; 23 | float startSize = 0.0f; 24 | float endSize = 0.0f; 25 | double rotSpeed = 0; 26 | 27 | // Particles emission 28 | int emissionRate = 0; 29 | uint emitNumber = 0u; 30 | uint emitVariance = 0u; 31 | uint maxParticleLife = 0u; 32 | uint maxParticlesPerFrame = 0u; 33 | 34 | // Pool 35 | ParticlePool* emitterPool = nullptr; 36 | int poolSize = 0; 37 | 38 | // Emission time 39 | j1PerfTimer stopTimer; 40 | j1PerfTimer emissionTimer; 41 | j1PerfTimer lifeTimer; 42 | double stopTime = 0.0f; 43 | double emissionTime = 0.0f; 44 | double lifetime = -1.0f; 45 | bool active = false; 46 | 47 | // Color and render properties 48 | SDL_Color startColor = { 0, 0, 0, 0 }; 49 | SDL_Color endColor = { 0, 0, 0, 0 }; 50 | SDL_Rect textureRect; 51 | SDL_BlendMode blendMode = SDL_BlendMode::SDL_BLENDMODE_NONE; 52 | float timeStep = 0.0f; 53 | 54 | // Random control parameters 55 | fPoint rotSpeedRand = { 0.0f, 0.0f }; 56 | fPoint startSpeedRand = { 0.0f, 0.0f }; 57 | fPoint endSpeedRand = { 0.0f, 0.0f }; 58 | fPoint emitVarianceRand = { 0.0f, 0.0f }; 59 | fPoint lifeRand = { 0.0f, 0.0f }; 60 | fPoint startSizeRand = { 0.0f, 0.0f }; 61 | fPoint endSizeRand = { 0.0f, 0.0f }; 62 | 63 | // Vortex control parameters 64 | bool vortexSensitive = false; 65 | 66 | public: 67 | 68 | Emitter(fPoint pos, EmitterData data); 69 | // fPoint pos, uint emitNumber, uint emitVariance, uint maxParticleLife, fPoint angleRange, double rotSpeed, float maxSpeed, float startSize, float endSize, SDL_Rect textureRect, SDL_Color startColor = { 0, 0, 0, 0 }, SDL_Color endColor = { 0, 0, 0, 0 }, SDL_BlendMode blendMode = SDL_BlendMode::SDL_BLENDMODE_NONE, double lifetime = -1.0f 70 | virtual ~Emitter(); 71 | 72 | void Update(float dt); 73 | bool Draw(float dt); 74 | 75 | // Generates random number between given range 76 | float RangeRandomNum(float min = -1.0f, float max = 1.0f); 77 | 78 | // Returns emitter pool size 79 | int GetPoolSize() const; 80 | 81 | // Starts emission specified by timer, if not emission time is infinite 82 | void StartEmission(double timer = -1.0f); 83 | 84 | // Stops emission specified by timer, if not emission stop time is infinite 85 | void StopEmission(double timer = 0.0f); 86 | 87 | // Emitter move methods 88 | void MoveEmitter(fPoint newPos); 89 | fPoint GetEmitterPos() const; 90 | 91 | void VortexSensitive(bool sensitive); 92 | }; 93 | 94 | #endif -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/Particle.h: -------------------------------------------------------------------------------- 1 | #ifndef __PARTICLE_H__ 2 | #define __PARTICLE_H__ 3 | 4 | #include "p2Point.h" 5 | #include "SDL/include/SDL.h" 6 | 7 | #define MIN_LIFE_TO_INTERPOLATE 15 8 | 9 | struct SDL_Texture; 10 | 11 | class Particle 12 | { 13 | private: 14 | 15 | /* This is the only variable we care about no matter if 16 | the particle is alive or dead */ 17 | uint life = 0; 18 | 19 | struct Vortex 20 | { 21 | fPoint pos = { 0.0f, 0.0f }; 22 | float speed = 0.0f; 23 | float scale = 0.0f; 24 | } vortex; 25 | 26 | union ParticleInfo 27 | { 28 | /* This struct holds the state of the particle when 29 | it's being update (it's still alive).*/ 30 | struct ParticleState 31 | { 32 | uint startLife; 33 | fPoint pos; 34 | fPoint startVel; 35 | fPoint endVel; 36 | fPoint currentVel; 37 | float currentSize, startSize, endSize; 38 | float ageRatio; 39 | float angle; 40 | double startRotSpeed; 41 | double currentRotSpeed; 42 | SDL_Rect pRect; 43 | SDL_Rect rectSize; 44 | SDL_Color startColor; 45 | SDL_Color endColor; 46 | SDL_BlendMode blendMode; 47 | bool vortexSensitive; 48 | float t; 49 | 50 | ParticleState() {} 51 | 52 | } pLive; 53 | 54 | /* If the particle is dead, then the 'next' member comes 55 | into play and the struct it's not used. This pointer 56 | called 'next' holds a pointer to the next available 57 | particle after this one. */ 58 | Particle* next; 59 | 60 | ParticleInfo() {} 61 | } pState; 62 | 63 | public: 64 | 65 | Particle(); 66 | 67 | // Initializes new generated particle 68 | void Init(fPoint pos, float startSpeed, float endSpeed, float angle, double rotSpeed, float startSize, float endSize, uint life, SDL_Rect textureRect, SDL_Color startColor, SDL_Color endColor, SDL_BlendMode blendMode, bool vortexSensitive); 69 | 70 | // Generic methods 71 | void Update(float dt); 72 | bool Draw(); 73 | bool IsAlive(); 74 | 75 | // Particle pointer methods 76 | Particle* GetNext(); 77 | void SetNext(Particle* next); 78 | 79 | // Given two colors interpolates linearly over time and returns the resulting color 80 | SDL_Color RgbInterpolation(SDL_Color startColor, float timeStep, SDL_Color endColor); 81 | 82 | float InterpolateBetweenRange(float min, float timeStep, float max); 83 | 84 | // Adds a vortex to the system 85 | void AddVortex(fPoint pos, float speed, float scale); 86 | 87 | /* Calculates particle position considering its velocity 88 | and if there's a vortex in the system */ 89 | void CalculateParticlePos(float dt); 90 | }; 91 | 92 | #endif -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/ParticlePool.cpp: -------------------------------------------------------------------------------- 1 | #include "ParticlePool.h" 2 | #include 3 | 4 | 5 | #include "Brofiler\Brofiler.h" 6 | 7 | 8 | // This pool constructor sets our particles to available 9 | ParticlePool::ParticlePool(Emitter* emitter) 10 | { 11 | // Fill the pool according to poolSize needed for the emitter 12 | poolSize = emitter->GetPoolSize(); 13 | particleArray = new Particle[poolSize]; 14 | 15 | // The first particle is available 16 | firstAvailable = &particleArray[0]; 17 | 18 | // Each particle points to the next one 19 | for (int i = 0; i < poolSize - 1; i++) 20 | particleArray[i].SetNext(&particleArray[i + 1]); 21 | 22 | // The last particle points to nullptr indicating the end of the vector 23 | particleArray[poolSize - 1].SetNext(nullptr); 24 | } 25 | 26 | ParticlePool::~ParticlePool() 27 | { 28 | delete[] particleArray; 29 | particleArray = nullptr; 30 | } 31 | 32 | void ParticlePool::Generate(fPoint pos, float startSpeed, float endSpeed, float angle, float rotSpeed, float startSize, float endSize, uint life, SDL_Rect textureRect, SDL_Color startColor, SDL_Color endColor, SDL_BlendMode blendMode, bool vortexSensitive) 33 | { 34 | // Check if the pool is not full 35 | assert(firstAvailable != nullptr); 36 | 37 | // Remove it from the available list 38 | Particle* newParticle = firstAvailable; 39 | firstAvailable = newParticle->GetNext(); 40 | 41 | // Initialize new alive particle 42 | newParticle->Init(pos, startSpeed, endSpeed, angle, rotSpeed, startSize, endSize, life, textureRect, startColor, endColor, blendMode, vortexSensitive); 43 | } 44 | 45 | ParticleState ParticlePool::Update(float dt) 46 | { 47 | ParticleState retState = ParticleState::PARTICLE_STATE_NOT_DEF; 48 | 49 | BROFILER_CATEGORY("Pool update", Profiler::Color::LightCyan) 50 | for (int i = 0; i < poolSize; i++) 51 | { 52 | if (particleArray[i].IsAlive()) 53 | { 54 | particleArray[i].Update(dt); 55 | 56 | if (particleArray[i].Draw()) 57 | retState = ParticleState::PARTICLE_ALIVE_DRAWN; 58 | else 59 | retState = ParticleState::PARTICLE_ALIVE_NOT_DRAWN; 60 | } 61 | else // if a particle dies it becomes the first available in the pool 62 | { 63 | // Add this particle to the front of the vector 64 | particleArray[i].SetNext(firstAvailable); 65 | firstAvailable = &particleArray[i]; 66 | retState = ParticleState::PARTICLE_DEAD; 67 | } 68 | } 69 | 70 | return retState; 71 | } -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/ParticlePool.h: -------------------------------------------------------------------------------- 1 | #ifndef __PARTICLE_POOL_H__ 2 | #define __PARTICLE_POOL_H__ 3 | 4 | #include "Particle.h" 5 | #include "Emitter.h" 6 | #include "p2Point.h" 7 | #include 8 | 9 | class Emitter; 10 | 11 | enum ParticleState 12 | { 13 | PARTICLE_STATE_NOT_DEF, 14 | PARTICLE_ALIVE_DRAWN, 15 | PARTICLE_ALIVE_NOT_DRAWN, 16 | PARTICLE_DEAD 17 | }; 18 | 19 | class ParticlePool 20 | { 21 | private: 22 | 23 | int poolSize = 0; 24 | Particle* firstAvailable; 25 | Particle* particleArray = nullptr; 26 | 27 | public: 28 | 29 | ParticlePool(Emitter* emitter); 30 | virtual ~ParticlePool(); 31 | 32 | // Generates a new particle each time it's called 33 | void Generate(fPoint pos, float startSpeed, float endSpeed, float angle, float rotSpeed, float startSize, float endSize, uint life, SDL_Rect textureRect, SDL_Color startColor, SDL_Color endColor, SDL_BlendMode blendMode, bool vortexSensitive); 34 | 35 | // Update (move and draw) particles in the pool. 36 | // IMPORTANT NOTE: This method returns: 37 | // - PARTICLE_ALIVE_DRAWN: if the particle is still alive and has been drawn succesfully 38 | // - PARTICLE_ALIVE_NOT_DRAWN: if the particle is alive and has NOT been drawn succesfully 39 | // - PARTICLE_DEAD: if is particle is no longer alive 40 | 41 | ParticleState Update(float dt); 42 | }; 43 | 44 | #endif -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/PugiXml/readme.txt: -------------------------------------------------------------------------------- 1 | pugixml 1.6 - an XML processing library 2 | 3 | Copyright (C) 2006-2015, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) 4 | Report bugs and download new versions at http://pugixml.org/ 5 | 6 | This is the distribution of pugixml, which is a C++ XML processing library, 7 | which consists of a DOM-like interface with rich traversal/modification 8 | capabilities, an extremely fast XML parser which constructs the DOM tree from 9 | an XML file/buffer, and an XPath 1.0 implementation for complex data-driven 10 | tree queries. Full Unicode support is also available, with Unicode interface 11 | variants and conversions between different Unicode encodings (which happen 12 | automatically during parsing/saving). 13 | 14 | The distribution contains the following folders: 15 | 16 | contrib/ - various contributions to pugixml 17 | 18 | docs/ - documentation 19 | docs/samples - pugixml usage examples 20 | docs/quickstart.html - quick start guide 21 | docs/manual.html - complete manual 22 | 23 | scripts/ - project files for IDE/build systems 24 | 25 | src/ - header and source files 26 | 27 | readme.txt - this file. 28 | 29 | This library is distributed under the MIT License: 30 | 31 | Copyright (c) 2006-2015 Arseny Kapoulkine 32 | 33 | Permission is hereby granted, free of charge, to any person 34 | obtaining a copy of this software and associated documentation 35 | files (the "Software"), to deal in the Software without 36 | restriction, including without limitation the rights to use, 37 | copy, modify, merge, publish, distribute, sublicense, and/or sell 38 | copies of the Software, and to permit persons to whom the 39 | Software is furnished to do so, subject to the following 40 | conditions: 41 | 42 | The above copyright notice and this permission notice shall be 43 | included in all copies or substantial portions of the Software. 44 | 45 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 46 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 47 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 48 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 49 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 50 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 51 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 52 | OTHER DEALINGS IN THE SOFTWARE. 53 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/PugiXml/src/pugiconfig.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * pugixml parser - version 1.6 3 | * -------------------------------------------------------- 4 | * Copyright (C) 2006-2015, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) 5 | * Report bugs and download new versions at http://pugixml.org/ 6 | * 7 | * This library is distributed under the MIT License. See notice at the end 8 | * of this file. 9 | * 10 | * This work is based on the pugxml parser, which is: 11 | * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) 12 | */ 13 | 14 | #ifndef HEADER_PUGICONFIG_HPP 15 | #define HEADER_PUGICONFIG_HPP 16 | 17 | // Uncomment this to enable wchar_t mode 18 | // #define PUGIXML_WCHAR_MODE 19 | 20 | // Uncomment this to disable XPath 21 | // #define PUGIXML_NO_XPATH 22 | 23 | // Uncomment this to disable STL 24 | // #define PUGIXML_NO_STL 25 | 26 | // Uncomment this to disable exceptions 27 | // #define PUGIXML_NO_EXCEPTIONS 28 | 29 | // Set this to control attributes for public classes/functions, i.e.: 30 | // #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL 31 | // #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL 32 | // #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall 33 | // In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead 34 | 35 | // Tune these constants to adjust memory-related behavior 36 | // #define PUGIXML_MEMORY_PAGE_SIZE 32768 37 | // #define PUGIXML_MEMORY_OUTPUT_STACK 10240 38 | // #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 39 | 40 | // Uncomment this to switch to header-only version 41 | // #define PUGIXML_HEADER_ONLY 42 | 43 | // Uncomment this to enable long long support 44 | // #define PUGIXML_HAS_LONG_LONG 45 | 46 | #endif 47 | 48 | /** 49 | * Copyright (c) 2006-2015 Arseny Kapoulkine 50 | * 51 | * Permission is hereby granted, free of charge, to any person 52 | * obtaining a copy of this software and associated documentation 53 | * files (the "Software"), to deal in the Software without 54 | * restriction, including without limitation the rights to use, 55 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 56 | * copies of the Software, and to permit persons to whom the 57 | * Software is furnished to do so, subject to the following 58 | * conditions: 59 | * 60 | * The above copyright notice and this permission notice shall be 61 | * included in all copies or substantial portions of the Software. 62 | * 63 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 64 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 65 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 66 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 67 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 68 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 69 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 70 | * OTHER DEALINGS IN THE SOFTWARE. 71 | */ 72 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/BUGS.txt: -------------------------------------------------------------------------------- 1 | 2 | Bugs are now managed in the SDL bug tracker, here: 3 | 4 | http://bugzilla.libsdl.org/ 5 | 6 | You may report bugs there, and search to see if a given issue has already 7 | been reported, discussed, and maybe even fixed. 8 | 9 | 10 | You may also find help on the SDL mailing list. Subscription information: 11 | 12 | http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org 13 | 14 | Bug reports are welcome here, but we really appreciate if you use Bugzilla, as 15 | bugs discussed on the mailing list may be forgotten or missed. 16 | 17 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/COPYING.txt: -------------------------------------------------------------------------------- 1 | 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | 21 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/README-SDL.txt: -------------------------------------------------------------------------------- 1 | 2 | Please distribute this file with the SDL runtime environment: 3 | 4 | The Simple DirectMedia Layer (SDL for short) is a cross-platform library 5 | designed to make it easy to write multi-media software, such as games and 6 | emulators. 7 | 8 | The Simple DirectMedia Layer library source code is available from: 9 | http://www.libsdl.org/ 10 | 11 | This library is distributed under the terms of the zlib license: 12 | http://www.zlib.net/zlib_license.html 13 | 14 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/README.txt: -------------------------------------------------------------------------------- 1 | 2 | Simple DirectMedia Layer 3 | 4 | (SDL) 5 | 6 | Version 2.0 7 | 8 | --- 9 | http://www.libsdl.org/ 10 | 11 | Simple DirectMedia Layer is a cross-platform development library designed 12 | to provide low level access to audio, keyboard, mouse, joystick, and graphics 13 | hardware via OpenGL and Direct3D. It is used by video playback software, 14 | emulators, and popular games including Valve's award winning catalog 15 | and many Humble Bundle games. 16 | 17 | SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. 18 | Support for other platforms may be found in the source code. 19 | 20 | SDL is written in C, works natively with C++, and there are bindings 21 | available for several other languages, including C# and Python. 22 | 23 | This library is distributed under the zlib license, which can be found 24 | in the file "COPYING.txt". 25 | 26 | The best way to learn how to use SDL is to check out the header files in 27 | the "include" subdirectory and the programs in the "test" subdirectory. 28 | The header files and test programs are well commented and always up to date. 29 | More documentation and FAQs are available online at: 30 | http://wiki.libsdl.org/ 31 | 32 | If you need help with the library, or just want to discuss SDL related 33 | issues, you can join the developers mailing list: 34 | http://www.libsdl.org/mailing-list.php 35 | 36 | If you want to report bugs or contribute patches, please submit them to 37 | bugzilla: 38 | http://bugzilla.libsdl.org/ 39 | 40 | Enjoy! 41 | Sam Lantinga (slouken@libsdl.org) 42 | 43 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_bits.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_bits.h 24 | * 25 | * Functions for fiddling with bits and bitmasks. 26 | */ 27 | 28 | #ifndef _SDL_bits_h 29 | #define _SDL_bits_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \file SDL_bits.h 41 | */ 42 | 43 | /** 44 | * Get the index of the most significant bit. Result is undefined when called 45 | * with 0. This operation can also be stated as "count leading zeroes" and 46 | * "log base 2". 47 | * 48 | * \return Index of the most significant bit, or -1 if the value is 0. 49 | */ 50 | SDL_FORCE_INLINE int 51 | SDL_MostSignificantBitIndex32(Uint32 x) 52 | { 53 | #if defined(__GNUC__) && __GNUC__ >= 4 54 | /* Count Leading Zeroes builtin in GCC. 55 | * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html 56 | */ 57 | if (x == 0) { 58 | return -1; 59 | } 60 | return 31 - __builtin_clz(x); 61 | #else 62 | /* Based off of Bit Twiddling Hacks by Sean Eron Anderson 63 | * , released in the public domain. 64 | * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog 65 | */ 66 | const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; 67 | const int S[] = {1, 2, 4, 8, 16}; 68 | 69 | int msbIndex = 0; 70 | int i; 71 | 72 | if (x == 0) { 73 | return -1; 74 | } 75 | 76 | for (i = 4; i >= 0; i--) 77 | { 78 | if (x & b[i]) 79 | { 80 | x >>= S[i]; 81 | msbIndex |= S[i]; 82 | } 83 | } 84 | 85 | return msbIndex; 86 | #endif 87 | } 88 | 89 | /* Ends C function definitions when using C++ */ 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | #include "close_code.h" 94 | 95 | #endif /* _SDL_bits_h */ 96 | 97 | /* vi: set ts=4 sw=4 expandtab: */ 98 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_blendmode.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_blendmode.h 24 | * 25 | * Header file declaring the SDL_BlendMode enumeration 26 | */ 27 | 28 | #ifndef _SDL_blendmode_h 29 | #define _SDL_blendmode_h 30 | 31 | #include "begin_code.h" 32 | /* Set up for C function definitions, even when using C++ */ 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** 38 | * \brief The blend mode used in SDL_RenderCopy() and drawing operations. 39 | */ 40 | typedef enum 41 | { 42 | SDL_BLENDMODE_NONE = 0x00000000, /**< no blending 43 | dstRGBA = srcRGBA */ 44 | SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending 45 | dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) 46 | dstA = srcA + (dstA * (1-srcA)) */ 47 | SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending 48 | dstRGB = (srcRGB * srcA) + dstRGB 49 | dstA = dstA */ 50 | SDL_BLENDMODE_MOD = 0x00000004 /**< color modulate 51 | dstRGB = srcRGB * dstRGB 52 | dstA = dstA */ 53 | } SDL_BlendMode; 54 | 55 | /* Ends C function definitions when using C++ */ 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | #include "close_code.h" 60 | 61 | #endif /* _SDL_blendmode_h */ 62 | 63 | /* vi: set ts=4 sw=4 expandtab: */ 64 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_clipboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_clipboard.h 24 | * 25 | * Include file for SDL clipboard handling 26 | */ 27 | 28 | #ifndef _SDL_clipboard_h 29 | #define _SDL_clipboard_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* Function prototypes */ 40 | 41 | /** 42 | * \brief Put UTF-8 text into the clipboard 43 | * 44 | * \sa SDL_GetClipboardText() 45 | */ 46 | extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); 47 | 48 | /** 49 | * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() 50 | * 51 | * \sa SDL_SetClipboardText() 52 | */ 53 | extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); 54 | 55 | /** 56 | * \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty 57 | * 58 | * \sa SDL_GetClipboardText() 59 | */ 60 | extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); 61 | 62 | 63 | /* Ends C function definitions when using C++ */ 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #include "close_code.h" 68 | 69 | #endif /* _SDL_clipboard_h */ 70 | 71 | /* vi: set ts=4 sw=4 expandtab: */ 72 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_error.h 24 | * 25 | * Simple error message routines for SDL. 26 | */ 27 | 28 | #ifndef _SDL_error_h 29 | #define _SDL_error_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* Public functions */ 40 | /* SDL_SetError() unconditionally returns -1. */ 41 | extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 42 | extern DECLSPEC const char *SDLCALL SDL_GetError(void); 43 | extern DECLSPEC void SDLCALL SDL_ClearError(void); 44 | 45 | /** 46 | * \name Internal error functions 47 | * 48 | * \internal 49 | * Private error reporting function - used internally. 50 | */ 51 | /* @{ */ 52 | #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) 53 | #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) 54 | #define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) 55 | typedef enum 56 | { 57 | SDL_ENOMEM, 58 | SDL_EFREAD, 59 | SDL_EFWRITE, 60 | SDL_EFSEEK, 61 | SDL_UNSUPPORTED, 62 | SDL_LASTERROR 63 | } SDL_errorcode; 64 | /* SDL_Error() unconditionally returns -1. */ 65 | extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code); 66 | /* @} *//* Internal error functions */ 67 | 68 | /* Ends C function definitions when using C++ */ 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | #include "close_code.h" 73 | 74 | #endif /* _SDL_error_h */ 75 | 76 | /* vi: set ts=4 sw=4 expandtab: */ 77 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_gesture.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_gesture.h 24 | * 25 | * Include file for SDL gesture event handling. 26 | */ 27 | 28 | #ifndef _SDL_gesture_h 29 | #define _SDL_gesture_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | 35 | #include "SDL_touch.h" 36 | 37 | 38 | #include "begin_code.h" 39 | /* Set up for C function definitions, even when using C++ */ 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | typedef Sint64 SDL_GestureID; 45 | 46 | /* Function prototypes */ 47 | 48 | /** 49 | * \brief Begin Recording a gesture on the specified touch, or all touches (-1) 50 | * 51 | * 52 | */ 53 | extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); 54 | 55 | 56 | /** 57 | * \brief Save all currently loaded Dollar Gesture templates 58 | * 59 | * 60 | */ 61 | extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst); 62 | 63 | /** 64 | * \brief Save a currently loaded Dollar Gesture template 65 | * 66 | * 67 | */ 68 | extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst); 69 | 70 | 71 | /** 72 | * \brief Load Dollar Gesture templates from a file 73 | * 74 | * 75 | */ 76 | extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); 77 | 78 | 79 | /* Ends C function definitions when using C++ */ 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | #include "close_code.h" 84 | 85 | #endif /* _SDL_gesture_h */ 86 | 87 | /* vi: set ts=4 sw=4 expandtab: */ 88 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDLname_h_ 23 | #define _SDLname_h_ 24 | 25 | #if defined(__STDC__) || defined(__cplusplus) 26 | #define NeedFunctionPrototypes 1 27 | #endif 28 | 29 | #define SDL_NAME(X) SDL_##X 30 | 31 | #endif /* _SDLname_h_ */ 32 | 33 | /* vi: set ts=4 sw=4 expandtab: */ 34 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_opengles.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_opengles.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 1.X API headers. 26 | */ 27 | 28 | #ifdef __IPHONEOS__ 29 | #include 30 | #include 31 | #else 32 | #include 33 | #include 34 | #endif 35 | 36 | #ifndef APIENTRY 37 | #define APIENTRY 38 | #endif 39 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_opengles2.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_opengles2.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. 26 | */ 27 | #ifndef _MSC_VER 28 | 29 | #ifdef __IPHONEOS__ 30 | #include 31 | #include 32 | #else 33 | #include 34 | #include 35 | #include 36 | #endif 37 | 38 | #else /* _MSC_VER */ 39 | 40 | /* OpenGL ES2 headers for Visual Studio */ 41 | #include "SDL_opengles2_khrplatform.h" 42 | #include "SDL_opengles2_gl2platform.h" 43 | #include "SDL_opengles2_gl2.h" 44 | #include "SDL_opengles2_gl2ext.h" 45 | 46 | #endif /* _MSC_VER */ 47 | 48 | #ifndef APIENTRY 49 | #define APIENTRY GL_APIENTRY 50 | #endif 51 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_opengles2_gl2platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __gl2platform_h_ 2 | #define __gl2platform_h_ 3 | 4 | /* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */ 5 | 6 | /* 7 | * This document is licensed under the SGI Free Software B License Version 8 | * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . 9 | */ 10 | 11 | /* Platform-specific types and definitions for OpenGL ES 2.X gl2.h 12 | * 13 | * Adopters may modify khrplatform.h and this file to suit their platform. 14 | * You are encouraged to submit all modifications to the Khronos group so that 15 | * they can be included in future versions of this file. Please submit changes 16 | * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) 17 | * by filing a bug against product "OpenGL-ES" component "Registry". 18 | */ 19 | 20 | /*#include */ 21 | 22 | #ifndef GL_APICALL 23 | #define GL_APICALL KHRONOS_APICALL 24 | #endif 25 | 26 | #ifndef GL_APIENTRY 27 | #define GL_APIENTRY KHRONOS_APIENTRY 28 | #endif 29 | 30 | #endif /* __gl2platform_h_ */ 31 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_power.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef _SDL_power_h 23 | #define _SDL_power_h 24 | 25 | /** 26 | * \file SDL_power.h 27 | * 28 | * Header for the SDL power management routines. 29 | */ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \brief The basic state for the system's power supply. 41 | */ 42 | typedef enum 43 | { 44 | SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ 45 | SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ 46 | SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ 47 | SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ 48 | SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ 49 | } SDL_PowerState; 50 | 51 | 52 | /** 53 | * \brief Get the current power supply details. 54 | * 55 | * \param secs Seconds of battery life left. You can pass a NULL here if 56 | * you don't care. Will return -1 if we can't determine a 57 | * value, or we're not running on a battery. 58 | * 59 | * \param pct Percentage of battery life left, between 0 and 100. You can 60 | * pass a NULL here if you don't care. Will return -1 if we 61 | * can't determine a value, or we're not running on a battery. 62 | * 63 | * \return The state of the battery (if any). 64 | */ 65 | extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); 66 | 67 | /* Ends C function definitions when using C++ */ 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | #include "close_code.h" 72 | 73 | #endif /* _SDL_power_h */ 74 | 75 | /* vi: set ts=4 sw=4 expandtab: */ 76 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_quit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_quit.h 24 | * 25 | * Include file for SDL quit event handling. 26 | */ 27 | 28 | #ifndef _SDL_quit_h 29 | #define _SDL_quit_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | /** 35 | * \file SDL_quit.h 36 | * 37 | * An ::SDL_QUIT event is generated when the user tries to close the application 38 | * window. If it is ignored or filtered out, the window will remain open. 39 | * If it is not ignored or filtered, it is queued normally and the window 40 | * is allowed to close. When the window is closed, screen updates will 41 | * complete, but have no effect. 42 | * 43 | * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) 44 | * and SIGTERM (system termination request), if handlers do not already 45 | * exist, that generate ::SDL_QUIT events as well. There is no way 46 | * to determine the cause of an ::SDL_QUIT event, but setting a signal 47 | * handler in your application will override the default generation of 48 | * quit events for that signal. 49 | * 50 | * \sa SDL_Quit() 51 | */ 52 | 53 | /* There are no functions directly affecting the quit event */ 54 | 55 | #define SDL_QuitRequested() \ 56 | (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0)) 57 | 58 | #endif /* _SDL_quit_h */ 59 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_revision.h: -------------------------------------------------------------------------------- 1 | #define SDL_REVISION "hg-10001:e12c38730512" 2 | #define SDL_REVISION_NUMBER 10001 3 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef _SDL_test_h 31 | #define _SDL_test_h 32 | 33 | #include "SDL.h" 34 | #include "SDL_test_common.h" 35 | #include "SDL_test_font.h" 36 | #include "SDL_test_random.h" 37 | #include "SDL_test_fuzzer.h" 38 | #include "SDL_test_crc32.h" 39 | #include "SDL_test_md5.h" 40 | #include "SDL_test_log.h" 41 | #include "SDL_test_assert.h" 42 | #include "SDL_test_harness.h" 43 | #include "SDL_test_images.h" 44 | #include "SDL_test_compare.h" 45 | 46 | #include "begin_code.h" 47 | /* Set up for C function definitions, even when using C++ */ 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | /* Global definitions */ 53 | 54 | /* 55 | * Note: Maximum size of SDLTest log message is less than SDL's limit 56 | * to ensure we can fit additional information such as the timestamp. 57 | */ 58 | #define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 59 | 60 | /* Ends C function definitions when using C++ */ 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | #include "close_code.h" 65 | 66 | #endif /* _SDL_test_h */ 67 | 68 | /* vi: set ts=4 sw=4 expandtab: */ 69 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_test_compare.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_compare.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Defines comparison functions (i.e. for surfaces). 33 | 34 | */ 35 | 36 | #ifndef _SDL_test_compare_h 37 | #define _SDL_test_compare_h 38 | 39 | #include "SDL.h" 40 | 41 | #include "SDL_test_images.h" 42 | 43 | #include "begin_code.h" 44 | /* Set up for C function definitions, even when using C++ */ 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /** 50 | * \brief Compares a surface and with reference image data for equality 51 | * 52 | * \param surface Surface used in comparison 53 | * \param referenceSurface Test Surface used in comparison 54 | * \param allowable_error Allowable difference (=sum of squared difference for each RGB component) in blending accuracy. 55 | * 56 | * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. 57 | */ 58 | int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); 59 | 60 | 61 | /* Ends C function definitions when using C++ */ 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #include "close_code.h" 66 | 67 | #endif /* _SDL_test_compare_h */ 68 | 69 | /* vi: set ts=4 sw=4 expandtab: */ 70 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_test_font.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_font.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef _SDL_test_font_h 31 | #define _SDL_test_font_h 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* Function prototypes */ 40 | 41 | #define FONT_CHARACTER_SIZE 8 42 | 43 | /** 44 | * \brief Draw a string in the currently set font. 45 | * 46 | * \param renderer The renderer to draw on. 47 | * \param x The X coordinate of the upper left corner of the character. 48 | * \param y The Y coordinate of the upper left corner of the character. 49 | * \param c The character to draw. 50 | * 51 | * \returns Returns 0 on success, -1 on failure. 52 | */ 53 | int SDLTest_DrawCharacter( SDL_Renderer *renderer, int x, int y, char c ); 54 | 55 | /** 56 | * \brief Draw a string in the currently set font. 57 | * 58 | * \param renderer The renderer to draw on. 59 | * \param x The X coordinate of the upper left corner of the string. 60 | * \param y The Y coordinate of the upper left corner of the string. 61 | * \param s The string to draw. 62 | * 63 | * \returns Returns 0 on success, -1 on failure. 64 | */ 65 | int SDLTest_DrawString( SDL_Renderer * renderer, int x, int y, const char *s ); 66 | 67 | 68 | /* Ends C function definitions when using C++ */ 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | #include "close_code.h" 73 | 74 | #endif /* _SDL_test_font_h */ 75 | 76 | /* vi: set ts=4 sw=4 expandtab: */ 77 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_test_images.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_images.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Defines some images for tests. 33 | 34 | */ 35 | 36 | #ifndef _SDL_test_images_h 37 | #define _SDL_test_images_h 38 | 39 | #include "SDL.h" 40 | 41 | #include "begin_code.h" 42 | /* Set up for C function definitions, even when using C++ */ 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /** 48 | *Type for test images. 49 | */ 50 | typedef struct SDLTest_SurfaceImage_s { 51 | int width; 52 | int height; 53 | unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ 54 | const char *pixel_data; 55 | } SDLTest_SurfaceImage_t; 56 | 57 | /* Test images */ 58 | SDL_Surface *SDLTest_ImageBlit(); 59 | SDL_Surface *SDLTest_ImageBlitColor(); 60 | SDL_Surface *SDLTest_ImageBlitAlpha(); 61 | SDL_Surface *SDLTest_ImageBlitBlendAdd(); 62 | SDL_Surface *SDLTest_ImageBlitBlend(); 63 | SDL_Surface *SDLTest_ImageBlitBlendMod(); 64 | SDL_Surface *SDLTest_ImageBlitBlendNone(); 65 | SDL_Surface *SDLTest_ImageBlitBlendAll(); 66 | SDL_Surface *SDLTest_ImageFace(); 67 | SDL_Surface *SDLTest_ImagePrimitives(); 68 | SDL_Surface *SDLTest_ImagePrimitivesBlend(); 69 | 70 | /* Ends C function definitions when using C++ */ 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | #include "close_code.h" 75 | 76 | #endif /* _SDL_test_images_h */ 77 | 78 | /* vi: set ts=4 sw=4 expandtab: */ 79 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_test_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_log.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | * 32 | * Wrapper to log in the TEST category 33 | * 34 | */ 35 | 36 | #ifndef _SDL_test_log_h 37 | #define _SDL_test_log_h 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /** 46 | * \brief Prints given message with a timestamp in the TEST category and INFO priority. 47 | * 48 | * \param fmt Message to be logged 49 | */ 50 | void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 51 | 52 | /** 53 | * \brief Prints given message with a timestamp in the TEST category and the ERROR priority. 54 | * 55 | * \param fmt Message to be logged 56 | */ 57 | void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 58 | 59 | /* Ends C function definitions when using C++ */ 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | #include "close_code.h" 64 | 65 | #endif /* _SDL_test_log_h */ 66 | 67 | /* vi: set ts=4 sw=4 expandtab: */ 68 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_touch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_touch.h 24 | * 25 | * Include file for SDL touch event handling. 26 | */ 27 | 28 | #ifndef _SDL_touch_h 29 | #define _SDL_touch_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | 35 | #include "begin_code.h" 36 | /* Set up for C function definitions, even when using C++ */ 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef Sint64 SDL_TouchID; 42 | typedef Sint64 SDL_FingerID; 43 | 44 | typedef struct SDL_Finger 45 | { 46 | SDL_FingerID id; 47 | float x; 48 | float y; 49 | float pressure; 50 | } SDL_Finger; 51 | 52 | /* Used as the device ID for mouse events simulated with touch input */ 53 | #define SDL_TOUCH_MOUSEID ((Uint32)-1) 54 | 55 | 56 | /* Function prototypes */ 57 | 58 | /** 59 | * \brief Get the number of registered touch devices. 60 | */ 61 | extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); 62 | 63 | /** 64 | * \brief Get the touch ID with the given index, or 0 if the index is invalid. 65 | */ 66 | extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); 67 | 68 | /** 69 | * \brief Get the number of active fingers for a given touch device. 70 | */ 71 | extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID); 72 | 73 | /** 74 | * \brief Get the finger object of the given touch, with the given index. 75 | */ 76 | extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index); 77 | 78 | /* Ends C function definitions when using C++ */ 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | #include "close_code.h" 83 | 84 | #endif /* _SDL_touch_h */ 85 | 86 | /* vi: set ts=4 sw=4 expandtab: */ 87 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/SDL_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_types.h 24 | * 25 | * \deprecated 26 | */ 27 | 28 | /* DEPRECATED */ 29 | #include "SDL_stdinc.h" 30 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/include/close_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file close_code.h 24 | * 25 | * This file reverses the effects of begin_code.h and should be included 26 | * after you finish any function and structure declarations in your headers 27 | */ 28 | 29 | #undef _begin_code_h 30 | 31 | /* Reset structure packing at previous byte alignment */ 32 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) 33 | #ifdef __BORLANDC__ 34 | #pragma nopackwarning 35 | #endif 36 | #pragma pack(pop) 37 | #endif /* Compiler needs structure packing set */ 38 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/libx86/SDL2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Motor2D/SDL/libx86/SDL2.lib -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL/libx86/SDL2main.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Motor2D/SDL/libx86/SDL2main.lib -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL_image/COPYING.txt: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_image: An example image loading library for use with SDL 3 | Copyright (C) 1997-2013 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL_image/README.txt: -------------------------------------------------------------------------------- 1 | 2 | SDL_image 2.0 3 | 4 | The latest version of this library is available from: 5 | http://www.libsdl.org/projects/SDL_image/ 6 | 7 | This is a simple library to load images of various formats as SDL surfaces. 8 | This library supports BMP, PNM (PPM/PGM/PBM), XPM, LBM, PCX, GIF, JPEG, PNG, 9 | TGA, and TIFF formats. 10 | 11 | API: 12 | #include "SDL_image.h" 13 | 14 | SDL_Surface *IMG_Load(const char *file); 15 | or 16 | SDL_Surface *IMG_Load_RW(SDL_RWops *src, int freesrc); 17 | or 18 | SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, char *type); 19 | 20 | where type is a string specifying the format (i.e. "PNG" or "pcx"). 21 | Note that IMG_Load_RW cannot load TGA images. 22 | 23 | To create a surface from an XPM image included in C source, use: 24 | 25 | SDL_Surface *IMG_ReadXPMFromArray(char **xpm); 26 | 27 | An example program 'showimage' is included, with source in showimage.c 28 | 29 | JPEG support requires the JPEG library: http://www.ijg.org/ 30 | PNG support requires the PNG library: http://www.libpng.org/pub/png/libpng.html 31 | and the Zlib library: http://www.gzip.org/zlib/ 32 | TIFF support requires the TIFF library: ftp://ftp.sgi.com/graphics/tiff/ 33 | 34 | If you have these libraries installed in non-standard places, you can 35 | try adding those paths to the configure script, e.g. 36 | sh ./configure CPPFLAGS="-I/somewhere/include" LDFLAGS="-L/somewhere/lib" 37 | If this works, you may need to add /somewhere/lib to your LD_LIBRARY_PATH 38 | so shared library loading works correctly. 39 | 40 | This library is under the zlib License, see the file "COPYING.txt" for details. 41 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL_image/libx86/SDL2_image.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Motor2D/SDL_image/libx86/SDL2_image.lib -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL_mixer/COPYING.txt: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2013 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL_mixer/README.txt: -------------------------------------------------------------------------------- 1 | 2 | SDL_mixer 2.0 3 | 4 | The latest version of this library is available from: 5 | http://www.libsdl.org/projects/SDL_mixer/ 6 | 7 | Due to popular demand, here is a simple multi-channel audio mixer. 8 | It supports 8 channels of 16 bit stereo audio, plus a single channel 9 | of music, mixed by the popular MikMod MOD, Timidity MIDI and SMPEG MP3 10 | libraries. 11 | 12 | See the header file SDL_mixer.h and the examples playwave.c and playmus.c 13 | for documentation on this mixer library. 14 | 15 | The mixer can currently load Microsoft WAVE files and Creative Labs VOC 16 | files as audio samples, and can load MIDI files via Timidity and the 17 | following music formats via MikMod: .MOD .S3M .IT .XM. It can load 18 | Ogg Vorbis streams as music if built with Ogg Vorbis or Tremor libraries, 19 | and finally it can load MP3 music using the SMPEG or libmad libraries. 20 | 21 | Tremor decoding is disabled by default; you can enable it by passing 22 | --enable-music-ogg-tremor 23 | to configure, or by defining OGG_MUSIC and OGG_USE_TREMOR. 24 | 25 | libmad decoding is disabled by default; you can enable it by passing 26 | --enable-music-mp3-mad 27 | to configure, or by defining MP3_MAD_MUSIC 28 | vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv 29 | WARNING: The license for libmad is GPL, which means that in order to 30 | use it your application must also be GPL! 31 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | 33 | The process of mixing MIDI files to wave output is very CPU intensive, 34 | so if playing regular WAVE files sound great, but playing MIDI files 35 | sound choppy, try using 8-bit audio, mono audio, or lower frequencies. 36 | 37 | To play MIDI files, you'll need to get a complete set of GUS patches 38 | from: 39 | http://www.libsdl.org/projects/mixer/timidity/timidity.tar.gz 40 | and unpack them in /usr/local/lib under UNIX, and C:\ under Win32. 41 | 42 | This library is under the zlib license, see the file "COPYING.txt" for details. 43 | 44 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/SDL_mixer/libx86/SDL2_mixer.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Motor2D/SDL_mixer/libx86/SDL2_mixer.lib -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/j1App.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1APP_H__ 2 | #define __j1APP_H__ 3 | 4 | #include 5 | #include 6 | #include "j1Module.h" 7 | #include "j1PerfTimer.h" 8 | #include "j1Timer.h" 9 | #include "PugiXml\src\pugixml.hpp" 10 | 11 | // Modules 12 | class j1Window; 13 | class j1Input; 14 | class j1Render; 15 | class j1Textures; 16 | class j1ParticleSystem; 17 | class j1Scene; 18 | 19 | 20 | class j1App 21 | { 22 | public: 23 | 24 | // Constructor 25 | j1App(int argc, char* args[]); 26 | 27 | // Destructor 28 | virtual ~j1App(); 29 | 30 | // Called before render is available 31 | bool Awake(); 32 | 33 | // Called before the first frame 34 | bool Start(); 35 | 36 | // Called each loop iteration 37 | bool Update(); 38 | 39 | // Called before quitting 40 | bool CleanUp(); 41 | 42 | // Add a new module to handle 43 | void AddModule(j1Module* module); 44 | 45 | // Exposing some properties for reading 46 | int GetArgc() const; 47 | const char* GetArgv(int index) const; 48 | const char* GetTitle() const; 49 | const char* GetOrganization() const; 50 | 51 | pugi::xml_node j1App::LoadEmitters(pugi::xml_document& psystem_file) const; 52 | 53 | 54 | private: 55 | 56 | // Load config file 57 | pugi::xml_node LoadConfig(pugi::xml_document&) const; 58 | 59 | // Call modules before each loop iteration 60 | void PrepareUpdate(); 61 | 62 | // Call modules before each loop iteration 63 | void FinishUpdate(); 64 | 65 | // Call modules before each loop iteration 66 | bool PreUpdate(); 67 | 68 | // Call modules on each loop iteration 69 | bool DoUpdate(); 70 | 71 | // Call modules after each loop iteration 72 | bool PostUpdate(); 73 | 74 | public: 75 | 76 | // Modules 77 | j1Window* win = nullptr; 78 | j1Input* input = nullptr; 79 | j1Render* render = nullptr; 80 | j1Textures* tex = nullptr; 81 | j1ParticleSystem* psystem = nullptr; 82 | j1Scene* scene = nullptr; 83 | 84 | float dt = 0.0f; 85 | 86 | private: 87 | 88 | std::list modules; 89 | int argc; 90 | char** args; 91 | 92 | std::string title; 93 | std::string organization; 94 | 95 | j1PerfTimer ptimer; 96 | uint64 frame_count = 0; 97 | j1Timer startup_time; 98 | j1Timer frame_time; 99 | j1Timer last_sec_frame_time; 100 | uint32 last_sec_frame_count = 0; 101 | uint32 prev_last_sec_frame_count = 0; 102 | int capped_ms = -1; 103 | 104 | }; 105 | 106 | extern j1App* App; 107 | 108 | #endif -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/j1Input.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1INPUT_H__ 2 | #define __j1INPUT_H__ 3 | 4 | #include "j1Module.h" 5 | 6 | //#define NUM_KEYS 352 7 | #define NUM_MOUSE_BUTTONS 5 8 | //#define LAST_KEYS_PRESSED_BUFFER 50 9 | 10 | struct SDL_Rect; 11 | 12 | enum j1EventWindow 13 | { 14 | WE_QUIT = 0, 15 | WE_HIDE = 1, 16 | WE_SHOW = 2, 17 | WE_COUNT 18 | }; 19 | 20 | enum j1KeyState 21 | { 22 | KEY_IDLE = 0, 23 | KEY_DOWN, 24 | KEY_REPEAT, 25 | KEY_UP 26 | }; 27 | 28 | class j1Input : public j1Module 29 | { 30 | 31 | public: 32 | 33 | j1Input(); 34 | 35 | // Destructor 36 | virtual ~j1Input(); 37 | 38 | // Called before render is available 39 | bool Awake(pugi::xml_node&); 40 | 41 | // Called before the first frame 42 | bool Start(); 43 | 44 | // Called each loop iteration 45 | bool PreUpdate(); 46 | 47 | // Called before quitting 48 | bool CleanUp(); 49 | 50 | // Gather relevant win events 51 | bool GetWindowEvent(j1EventWindow ev); 52 | 53 | // Check key states (includes mouse and joy buttons) 54 | j1KeyState GetKey(int id) const 55 | { 56 | return keyboard[id]; 57 | } 58 | 59 | j1KeyState GetMouseButtonDown(int id) const 60 | { 61 | return mouse_buttons[id - 1]; 62 | } 63 | 64 | // Check if a certain window event happened 65 | bool GetWindowEvent(int code); 66 | 67 | // Get mouse / axis position 68 | void GetMousePosition(int &x, int &y); 69 | void GetMouseMotion(int& x, int& y); 70 | 71 | private: 72 | bool windowEvents[WE_COUNT]; 73 | j1KeyState* keyboard; 74 | j1KeyState mouse_buttons[NUM_MOUSE_BUTTONS]; 75 | int mouse_motion_x; 76 | int mouse_motion_y; 77 | int mouse_x; 78 | int mouse_y; 79 | }; 80 | 81 | #endif // __j1INPUT_H__ -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/j1Module.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------- 2 | // j1Module.h 3 | // Interface for all engine modules 4 | // ---------------------------------------------------- 5 | 6 | #ifndef __j1MODULE_H__ 7 | #define __j1MODULE_H__ 8 | 9 | #include 10 | #include "PugiXml\src\pugixml.hpp" 11 | 12 | class j1App; 13 | 14 | class j1Module 15 | { 16 | public: 17 | 18 | j1Module() : active(false) 19 | {} 20 | 21 | virtual ~j1Module() 22 | {} 23 | 24 | void Init() 25 | { 26 | active = true; 27 | } 28 | 29 | // Called before render is available 30 | virtual bool Awake(pugi::xml_node&) 31 | { 32 | return true; 33 | } 34 | 35 | // Called before the first frame 36 | virtual bool Start() 37 | { 38 | return true; 39 | } 40 | 41 | // Called each loop iteration 42 | virtual bool PreUpdate() 43 | { 44 | return true; 45 | } 46 | 47 | // Called each loop iteration 48 | virtual bool Update(float dt) 49 | { 50 | return true; 51 | } 52 | 53 | // Called each loop iteration 54 | virtual bool PostUpdate() 55 | { 56 | return true; 57 | } 58 | 59 | // Called before quitting 60 | virtual bool CleanUp() 61 | { 62 | return true; 63 | } 64 | 65 | virtual bool Load(pugi::xml_node&) 66 | { 67 | return true; 68 | } 69 | 70 | virtual bool Save(pugi::xml_node&) const 71 | { 72 | return true; 73 | } 74 | 75 | public: 76 | 77 | std::string name; 78 | bool active; 79 | 80 | }; 81 | 82 | #endif // __j1MODULE_H__ -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/j1ParticleSystem.h: -------------------------------------------------------------------------------- 1 | #ifndef __PARTICLE_SYSTEM_H__ 2 | #define __PARTICLE_SYSTEM_H__ 3 | 4 | #include "p2Point.h" 5 | #include "j1Module.h" 6 | #include "Emitter.h" 7 | #include 8 | #include 9 | #include "SDL/include/SDL.h" 10 | 11 | #define MAX_NUM_EMITTERS_TYPE 11 12 | 13 | class Emitter; 14 | struct SDL_Texture; 15 | struct SDL_Rect; 16 | struct SDL_Color; 17 | 18 | enum EmitterType 19 | { 20 | EMITTER_TYPE_NONE = -1, 21 | EMITTER_TYPE_FIRE, 22 | EMITTER_TYPE_FIRE_PURPLE, 23 | EMITTER_TYPE_FLAME, 24 | EMITTER_TYPE_SMOKE, 25 | EMITTER_TYPE_PIXEL_SMOKE, 26 | EMITTER_TYPE_BURST, 27 | EMITTER_TYPE_WAVE_1, 28 | EMITTER_TYPE_WAVE_2, 29 | EMITTER_TYPE_BUBBLE, 30 | EMITTER_TYPE_SPARK 31 | }; 32 | 33 | struct EmitterData 34 | { 35 | fPoint angleRange = { 0.0f, 0.0f }; 36 | float startSpeed = 0.0f, endSpeed = 0.0f; 37 | float startSize = 0.0f, endSize = 0.0f; 38 | uint emitNumber = 0u; 39 | uint emitVariance = 0u; 40 | uint maxParticleLife = 0u; 41 | SDL_Rect textureRect = { 0, 0 }; 42 | double lifetime = -1.0f; 43 | SDL_Color startColor = { 0, 0, 0, 0 }; 44 | SDL_Color endColor = { 0, 0, 0, 0 }; 45 | SDL_BlendMode blendMode = SDL_BlendMode::SDL_BLENDMODE_NONE; 46 | double rotSpeed = 0; 47 | 48 | // Randoms 49 | fPoint rotSpeedRand = { 0.0f, 0.0f }; 50 | fPoint startSpeedRand = { 0.0f, 0.0f }; 51 | fPoint endSpeedRand = { 0.0f, 0.0f }; 52 | fPoint emitVarianceRand = { 0.0f, 0.0f }; 53 | fPoint lifeRand = { 0.0f, 0.0f }; 54 | fPoint startSizeRand = { 0.0f, 0.0f }; 55 | fPoint endSizeRand = { 0.0f, 0.0f }; 56 | 57 | // Vortex 58 | bool vortexSensitive = false; 59 | }; 60 | 61 | class j1ParticleSystem : public j1Module 62 | { 63 | 64 | private: 65 | 66 | std::list emittersList; 67 | std::list emittersToDestroy; 68 | SDL_Texture* particleAtlas = nullptr; 69 | std::string nameParticleAtlas; 70 | 71 | // Static array that stores all the data of emitters 72 | EmitterData vecEmitterData[MAX_NUM_EMITTERS_TYPE]; 73 | 74 | public: 75 | 76 | j1ParticleSystem(); 77 | 78 | // Destructor 79 | virtual ~j1ParticleSystem(); 80 | 81 | // Called when before render is available 82 | bool Awake(pugi::xml_node& config); 83 | 84 | // Call before first frame 85 | bool Start(); 86 | 87 | // Called before all Updates 88 | bool PreUpdate(); 89 | 90 | // Called each loop iteration 91 | bool Update(float dt); 92 | 93 | // Called after all Updates 94 | bool PostUpdate(); 95 | 96 | // Called before quitting 97 | bool CleanUp(); 98 | 99 | // Emitter methods 100 | Emitter* AddEmiter(fPoint pos, EmitterType type); 101 | bool RemoveEmitter(Emitter* emitter); 102 | bool RemoveAllEmitters(); 103 | 104 | SDL_Texture* GetParticleAtlas() const; 105 | void LoadEmitterData(pugi::xml_node& config, EmitterType type); 106 | }; 107 | 108 | #endif // __PARTICLE_SYSTEM_H__ -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/j1PerfTimer.cpp: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------- 2 | // j1PerfTimer.cpp 3 | // Slow timer with microsecond precision 4 | // ---------------------------------------------------- 5 | 6 | #include "j1PerfTimer.h" 7 | #include "SDL\include\SDL_timer.h" 8 | 9 | uint64 j1PerfTimer::frequency = 0; 10 | 11 | // --------------------------------------------- 12 | j1PerfTimer::j1PerfTimer() 13 | { 14 | if (frequency == 0) 15 | frequency = SDL_GetPerformanceFrequency(); 16 | 17 | Start(); 18 | } 19 | 20 | // --------------------------------------------- 21 | void j1PerfTimer::Start() 22 | { 23 | started_at = SDL_GetPerformanceCounter(); 24 | } 25 | 26 | // --------------------------------------------- 27 | double j1PerfTimer::ReadMs() const 28 | { 29 | return 1000.0 * (double(SDL_GetPerformanceCounter() - started_at) / double(frequency)); 30 | } 31 | 32 | // --------------------------------------------- 33 | uint64 j1PerfTimer::ReadTicks() const 34 | { 35 | return SDL_GetPerformanceCounter() - started_at; 36 | } -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/j1PerfTimer.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1PERFTIMER_H__ 2 | #define __j1PERFTIMER_H__ 3 | 4 | #include "p2Defs.h" 5 | 6 | class j1PerfTimer 7 | { 8 | public: 9 | 10 | // Constructor 11 | j1PerfTimer(); 12 | 13 | void Start(); 14 | double ReadMs() const; 15 | uint64 ReadTicks() const; 16 | 17 | private: 18 | uint64 started_at; 19 | static uint64 frequency; 20 | }; 21 | 22 | #endif //__j1PERFTIMER_H__ -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/j1Render.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1RENDER_H__ 2 | #define __j1RENDER_H__ 3 | 4 | #include "SDL/include/SDL.h" 5 | #include "j1Module.h" 6 | 7 | class j1Render : public j1Module 8 | { 9 | public: 10 | 11 | j1Render(); 12 | 13 | // Destructor 14 | virtual ~j1Render(); 15 | 16 | // Called before render is available 17 | bool Awake(pugi::xml_node&); 18 | 19 | // Called before the first frame 20 | bool Start(); 21 | 22 | // Called each loop iteration 23 | bool PreUpdate(); 24 | bool Update(float dt); 25 | bool PostUpdate(); 26 | 27 | // Called before quitting 28 | bool CleanUp(); 29 | 30 | // Load / Save 31 | bool Load(pugi::xml_node&); 32 | bool Save(pugi::xml_node&) const; 33 | 34 | // Blit 35 | void SetViewPort(const SDL_Rect& rect); 36 | void ResetViewPort(); 37 | bool BlitParticle(SDL_Texture* texture, int x, int y, const SDL_Rect* section = NULL, const SDL_Rect* rectSize = NULL, SDL_Color color = { 0, 0, 0, 0 }, SDL_BlendMode blendMode = SDL_BLENDMODE_NONE, float speed = 1.0f, double angle = 0, int pivot_x = INT_MAX, int pivot_y = INT_MAX) const; 38 | bool Blit(SDL_Texture* texture, int x, int y, const SDL_Rect* section, float speed = 1.0f, double angle = 0, int pivot_x = INT_MAX, int pivot_y = INT_MAX) const; 39 | bool DrawQuad(const SDL_Rect& rect, Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255, bool filled = true, bool use_camera = true) const; 40 | bool DrawLine(int x1, int y1, int x2, int y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255, bool use_camera = true) const; 41 | bool DrawCircle(int x1, int y1, int redius, Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255, bool filled = false, bool use_camera = true) const; 42 | 43 | // Set background color 44 | void SetBackgroundColor(SDL_Color color); 45 | 46 | public: 47 | 48 | SDL_Renderer* renderer; 49 | SDL_Rect camera; 50 | SDL_Rect viewport; 51 | SDL_Color background; 52 | }; 53 | 54 | #endif // __j1RENDER_H__ -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/j1Scene.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1SCENE_H__ 2 | #define __j1SCENE_H__ 3 | 4 | #include "j1Module.h" 5 | #include "Particle.h" 6 | #include "ParticlePool.h" 7 | #include "Emitter.h" 8 | #include "p2Point.h" 9 | 10 | struct SDL_Texture; 11 | 12 | class j1Scene : public j1Module 13 | { 14 | public: 15 | 16 | j1Scene(); 17 | 18 | // Destructor 19 | virtual ~j1Scene(); 20 | 21 | // Called before render is available 22 | bool Awake(); 23 | 24 | // Called before the first frame 25 | bool Start(); 26 | 27 | // Called before all Updates 28 | bool PreUpdate(); 29 | 30 | // Called each loop iteration 31 | bool Update(float dt); 32 | 33 | // Called before all Updates 34 | bool PostUpdate(); 35 | 36 | // Called before quitting 37 | bool CleanUp(); 38 | 39 | private: 40 | 41 | Emitter* eFire = nullptr; 42 | Emitter* eSmoke = nullptr; 43 | Emitter* eFlame = nullptr; 44 | Emitter* eWave_1 = nullptr; 45 | Emitter* eWave_2 = nullptr; 46 | Emitter* eBurst_1 = nullptr; 47 | Emitter* eBurst_2 = nullptr; 48 | Emitter* eBubbles = nullptr; 49 | Emitter* eSpark = nullptr; 50 | Emitter* ePixelSmoke = nullptr; 51 | SDL_Rect rect = { 0, 0, 400, 400 }; 52 | SDL_Texture* torchTex = nullptr; 53 | 54 | }; 55 | 56 | #endif // __j1SCENE_H__ -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/j1Textures.cpp: -------------------------------------------------------------------------------- 1 | #include "p2Defs.h" 2 | #include "p2Log.h" 3 | #include "j1App.h" 4 | #include "j1Render.h" 5 | #include "j1Textures.h" 6 | 7 | #include "SDL_image/include/SDL_image.h" 8 | #pragma comment( lib, "SDL_image/libx86/SDL2_image.lib" ) 9 | 10 | j1Textures::j1Textures() : j1Module() 11 | { 12 | name = "textures"; 13 | } 14 | 15 | j1Textures::~j1Textures() 16 | {} 17 | 18 | bool j1Textures::Awake(pugi::xml_node& texturesNode) 19 | { 20 | LOG("Init Image library"); 21 | bool ret = true; 22 | int flags = IMG_INIT_PNG; 23 | int init = IMG_Init(flags); 24 | 25 | if ((init & flags) != flags) 26 | { 27 | LOG("Could not initialize Image lib. IMG_Init: %s", IMG_GetError()); 28 | ret = false; 29 | } 30 | 31 | return ret; 32 | } 33 | 34 | bool j1Textures::Start() 35 | { 36 | LOG("start textures"); 37 | bool ret = true; 38 | return ret; 39 | } 40 | 41 | bool j1Textures::CleanUp() 42 | { 43 | LOG("Freeing textures and Image library"); 44 | std::list::const_iterator item; 45 | 46 | for (item = textures.begin(); item != textures.end(); ++item) 47 | { 48 | SDL_DestroyTexture(*item); 49 | } 50 | 51 | textures.clear(); 52 | IMG_Quit(); 53 | return true; 54 | } 55 | 56 | SDL_Texture* const j1Textures::Load(const char* path) 57 | { 58 | SDL_Texture* texture = NULL; 59 | SDL_Surface* surface = IMG_Load(path); 60 | 61 | if (surface == NULL) 62 | { 63 | LOG("Could not load surface with path: %s. IMG_Load: %s", path, IMG_GetError()); 64 | } 65 | else 66 | { 67 | texture = LoadSurface(surface); 68 | SDL_FreeSurface(surface); 69 | } 70 | 71 | if (texture != NULL) 72 | textures.push_back(texture); 73 | else 74 | return NULL; 75 | 76 | return texture; 77 | } 78 | 79 | bool j1Textures::UnLoad(SDL_Texture* texture) 80 | { 81 | std::list::const_iterator item; 82 | 83 | for (item = textures.begin(); item != textures.end(); ++item) 84 | { 85 | if (texture == (*item)) 86 | { 87 | SDL_DestroyTexture(*item); 88 | textures.remove(*item); 89 | return true; 90 | } 91 | } 92 | 93 | return false; 94 | } 95 | 96 | SDL_Texture* const j1Textures::LoadSurface(SDL_Surface* surface) 97 | { 98 | SDL_Texture* texture = SDL_CreateTextureFromSurface(App->render->renderer, surface); 99 | 100 | if (texture == NULL) 101 | { 102 | LOG("Unable to create texture from surface! SDL Error: %s\n", SDL_GetError()); 103 | } 104 | else 105 | return texture; 106 | 107 | return NULL; 108 | } 109 | 110 | void j1Textures::GetSize(const SDL_Texture* texture, uint& width, uint& height) const 111 | { 112 | SDL_QueryTexture((SDL_Texture*)texture, NULL, NULL, (int*)&width, (int*)&height); 113 | } -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/j1Textures.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1TEXTURES_H__ 2 | #define __j1TEXTURES_H__ 3 | 4 | #include "j1Module.h" 5 | #include 6 | 7 | struct SDL_Texture; 8 | struct SDL_Surface; 9 | 10 | class j1Textures : public j1Module 11 | { 12 | public: 13 | 14 | j1Textures(); 15 | virtual ~j1Textures(); 16 | 17 | bool Awake(pugi::xml_node&); 18 | bool Start(); 19 | bool CleanUp(); 20 | 21 | SDL_Texture* const Load(const char* path); 22 | bool UnLoad(SDL_Texture* texture); 23 | SDL_Texture* const LoadSurface(SDL_Surface* surface); 24 | void GetSize(const SDL_Texture* texture, uint& width, uint& height) const; 25 | 26 | public: 27 | 28 | std::list textures; 29 | }; 30 | 31 | 32 | #endif -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/j1Timer.cpp: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------- 2 | // j1Timer.cpp 3 | // Fast timer with milisecons precision 4 | // ---------------------------------------------------- 5 | 6 | #include "j1Timer.h" 7 | #include "SDL\include\SDL_timer.h" 8 | 9 | // --------------------------------------------- 10 | j1Timer::j1Timer() 11 | { 12 | Start(); 13 | } 14 | 15 | // --------------------------------------------- 16 | void j1Timer::Start() 17 | { 18 | started_at = SDL_GetTicks(); 19 | } 20 | 21 | // --------------------------------------------- 22 | uint32 j1Timer::Read() const 23 | { 24 | return SDL_GetTicks() - started_at; 25 | } 26 | 27 | // --------------------------------------------- 28 | float j1Timer::ReadSec() const 29 | { 30 | return float(SDL_GetTicks() - started_at) / 1000.0f; 31 | } -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/j1Timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1TIMER_H__ 2 | #define __j1TIMER_H__ 3 | 4 | #include "p2Defs.h" 5 | 6 | class j1Timer 7 | { 8 | public: 9 | 10 | // Constructor 11 | j1Timer(); 12 | 13 | void Start(); 14 | uint32 Read() const; 15 | float ReadSec() const; 16 | 17 | private: 18 | uint32 started_at; 19 | }; 20 | 21 | #endif //__j1TIMER_H__ -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/j1Window.cpp: -------------------------------------------------------------------------------- 1 | #include "p2Defs.h" 2 | #include "p2Log.h" 3 | #include "j1App.h" 4 | #include "j1Window.h" 5 | 6 | #include "SDL/include/SDL.h" 7 | 8 | 9 | j1Window::j1Window() : j1Module() 10 | { 11 | window = NULL; 12 | screen_surface = NULL; 13 | name = "window"; 14 | } 15 | 16 | // Destructor 17 | j1Window::~j1Window() 18 | { 19 | } 20 | 21 | // Called before render is available 22 | bool j1Window::Awake(pugi::xml_node& config) 23 | { 24 | LOG("Init SDL window & surface"); 25 | bool ret = true; 26 | 27 | if(SDL_Init(SDL_INIT_VIDEO) < 0) 28 | { 29 | LOG("SDL_VIDEO could not initialize! SDL_Error: %s\n", SDL_GetError()); 30 | ret = false; 31 | } 32 | else 33 | { 34 | //Create window 35 | Uint32 flags = SDL_WINDOW_SHOWN; 36 | bool fullscreen = config.child("fullscreen").attribute("value").as_bool(false); 37 | bool borderless = config.child("borderless").attribute("value").as_bool(false); 38 | bool resizable = config.child("resizable").attribute("value").as_bool(false); 39 | bool fullscreen_window = config.child("fullscreen_window").attribute("value").as_bool(false); 40 | 41 | width = config.child("resolution").attribute("width").as_int(640); 42 | height = config.child("resolution").attribute("height").as_int(480); 43 | scale = config.child("resolution").attribute("scale").as_int(1); 44 | 45 | if(fullscreen == true) 46 | { 47 | flags |= SDL_WINDOW_FULLSCREEN; 48 | } 49 | 50 | if(borderless == true) 51 | { 52 | flags |= SDL_WINDOW_BORDERLESS; 53 | } 54 | 55 | if(resizable == true) 56 | { 57 | flags |= SDL_WINDOW_RESIZABLE; 58 | } 59 | 60 | if(fullscreen_window == true) 61 | { 62 | flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; 63 | } 64 | 65 | window = SDL_CreateWindow(App->GetTitle(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags); 66 | 67 | if(window == NULL) 68 | { 69 | LOG("Window could not be created! SDL_Error: %s\n", SDL_GetError()); 70 | ret = false; 71 | } 72 | else 73 | { 74 | //Get window surface 75 | screen_surface = SDL_GetWindowSurface(window); 76 | } 77 | } 78 | 79 | return ret; 80 | } 81 | 82 | // Called before quitting 83 | bool j1Window::CleanUp() 84 | { 85 | LOG("Destroying SDL window and quitting all SDL systems"); 86 | 87 | //Destroy window 88 | if(window != NULL) 89 | { 90 | SDL_DestroyWindow(window); 91 | } 92 | 93 | //Quit SDL subsystems 94 | SDL_Quit(); 95 | return true; 96 | } 97 | 98 | // Set new window title 99 | void j1Window::SetTitle(const char* new_title) 100 | { 101 | //title.create(new_title); 102 | SDL_SetWindowTitle(window, new_title); 103 | } 104 | 105 | void j1Window::GetWindowSize(uint& width, uint& height) const 106 | { 107 | width = this->width; 108 | height = this->height; 109 | } 110 | 111 | uint j1Window::GetScale() const 112 | { 113 | return scale; 114 | } -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/j1Window.h: -------------------------------------------------------------------------------- 1 | #ifndef __j1WINDOW_H__ 2 | #define __j1WINDOW_H__ 3 | 4 | #include "j1Module.h" 5 | 6 | struct SDL_Window; 7 | struct SDL_Surface; 8 | 9 | class j1Window : public j1Module 10 | { 11 | public: 12 | 13 | j1Window(); 14 | 15 | // Destructor 16 | virtual ~j1Window(); 17 | 18 | // Called before render is available 19 | bool Awake(pugi::xml_node&); 20 | 21 | // Called before quitting 22 | bool CleanUp(); 23 | 24 | // Changae title 25 | void SetTitle(const char* new_title); 26 | 27 | // Retrive window size 28 | void GetWindowSize(uint& width, uint& height) const; 29 | 30 | // Retrieve window scale 31 | uint GetScale() const; 32 | 33 | public: 34 | //The window we'll be rendering to 35 | SDL_Window* window; 36 | 37 | //The surface contained by the window 38 | SDL_Surface* screen_surface; 39 | 40 | private: 41 | std::string title; 42 | std::string icon; 43 | 44 | // Screen parameters 45 | uint width = 0u; 46 | uint height = 0u; 47 | uint scale = 0u; 48 | }; 49 | 50 | #endif // __j1WINDOW_H__ -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/mmgr/nommgr.h: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------------------------------------------------------------- 2 | // _ 3 | // | | 4 | // _ __ ___ _ __ ___ _ __ ___ __ _ _ __ | |__ 5 | // | '_ \ / _ \| '_ ` _ \| '_ ` _ \ / _` | '__| | '_ \ 6 | // | | | | (_) | | | | | | | | | | | (_| | | _ | | | | 7 | // |_| |_|\___/|_| |_| |_|_| |_| |_|\__, |_| (_)|_| |_| 8 | // __/ | 9 | // |___/ 10 | // 11 | // Memory manager & tracking software 12 | // 13 | // Best viewed with 8-character tabs and (at least) 132 columns 14 | // 15 | // --------------------------------------------------------------------------------------------------------------------------------- 16 | // 17 | // Restrictions & freedoms pertaining to usage and redistribution of this software: 18 | // 19 | // * This software is 100% free 20 | // * If you use this software (in part or in whole) you must credit the author. 21 | // * This software may not be re-distributed (in part or in whole) in a modified 22 | // form without clear documentation on how to obtain a copy of the original work. 23 | // * You may not use this software to directly or indirectly cause harm to others. 24 | // * This software is provided as-is and without warrantee. Use at your own risk. 25 | // 26 | // For more information, visit HTTP://www.FluidStudios.com 27 | // 28 | // --------------------------------------------------------------------------------------------------------------------------------- 29 | // Originally created on 12/22/2000 by Paul Nettle 30 | // 31 | // Copyright 2000, Fluid Studios, Inc., all rights reserved. 32 | // --------------------------------------------------------------------------------------------------------------------------------- 33 | 34 | #ifdef new 35 | #undef new 36 | #endif 37 | 38 | #ifdef delete 39 | #undef delete 40 | #endif 41 | 42 | #ifdef malloc 43 | #undef malloc 44 | #endif 45 | 46 | #ifdef calloc 47 | #undef calloc 48 | #endif 49 | 50 | #ifdef realloc 51 | #undef realloc 52 | #endif 53 | 54 | #ifdef free 55 | #undef free 56 | #endif 57 | 58 | // --------------------------------------------------------------------------------------------------------------------------------- 59 | // nommgr.h - End of file 60 | // --------------------------------------------------------------------------------------------------------------------------------- 61 | -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/mmgr/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nintervik/2D-Particle-System/139545c222f434ae5e061829ff74858c7891d2a6/full_code/2D Particle System/Motor2D/mmgr/readme.txt -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/p2Defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __P2DEFS_H__ 2 | #define __P2DEFS_H__ 3 | 4 | #include 5 | 6 | // NULL just in case ---------------------- 7 | 8 | #ifdef NULL 9 | #undef NULL 10 | #endif 11 | #define NULL 0 12 | 13 | // Deletes a buffer 14 | #define RELEASE( x ) \ 15 | { \ 16 | if( x != NULL ) \ 17 | { \ 18 | delete x; \ 19 | x = NULL; \ 20 | } \ 21 | } 22 | 23 | // Deletes an array of buffers 24 | #define RELEASE_ARRAY( x ) \ 25 | { \ 26 | if( x != NULL ) \ 27 | { \ 28 | delete[] x; \ 29 | x = NULL; \ 30 | } \ 31 | \ 32 | } 33 | 34 | #define IN_RANGE( value, min, max ) ( ((value) >= (min) && (value) <= (max)) ? 1 : 0 ) 35 | #define MIN( a, b ) ( ((a) < (b)) ? (a) : (b) ) 36 | #define MAX( a, b ) ( ((a) > (b)) ? (a) : (b) ) 37 | #define TO_BOOL( a ) ( (a != 0) ? true : false ) 38 | 39 | typedef unsigned int uint; 40 | typedef unsigned __int8 uint8; 41 | typedef unsigned __int32 uint32; 42 | typedef unsigned __int64 uint64; 43 | typedef unsigned char uchar; 44 | 45 | template void SWAP(VALUE_TYPE& a, VALUE_TYPE& b) 46 | { 47 | VALUE_TYPE tmp = a; 48 | a = b; 49 | b = tmp; 50 | } 51 | 52 | // Standard string size 53 | #define SHORT_STR 32 54 | #define MID_STR 255 55 | #define HUGE_STR 8192 56 | 57 | // Joins a path and file 58 | inline const char* const PATH(const char* folder, const char* file) 59 | { 60 | static char path[MID_STR]; 61 | sprintf_s(path, MID_STR, "%s/%s", folder, file); 62 | return path; 63 | } 64 | 65 | // Performance macros 66 | #define PERF_START(timer) timer.Start() 67 | #define PERF_PEEK(timer) LOG("%s took %f ms", __FUNCTION__, timer.ReadMs()) 68 | 69 | // Maths calculations 70 | #define PI 3.14159265359f 71 | #define DEG_2_RAD(a) a * PI / 180.0f 72 | #define RAD_2_DEG(a) a * 180.0f / PI 73 | 74 | #endif -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/p2Log.cpp: -------------------------------------------------------------------------------- 1 | #include "p2Log.h" 2 | 3 | void log(const char file[], int line, const char* format, ...) 4 | { 5 | static char tmp_string[4096]; 6 | static char tmp_string2[4096]; 7 | static va_list ap; 8 | 9 | // Construct the string from variable arguments 10 | va_start(ap, format); 11 | vsprintf_s(tmp_string, 4096, format, ap); 12 | va_end(ap); 13 | sprintf_s(tmp_string2, 4096, "\n%s(%d) : %s", file, line, tmp_string); 14 | OutputDebugString(tmp_string2); 15 | } -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/p2Log.h: -------------------------------------------------------------------------------- 1 | #ifndef __p2Log_H__ 2 | #define __p2Log_H__ 3 | 4 | #include 5 | #include 6 | 7 | #define LOG(format, ...) log(__FILE__, __LINE__, format, __VA_ARGS__) 8 | 9 | void log(const char file[], int line, const char* format, ...); 10 | 11 | #endif -------------------------------------------------------------------------------- /full_code/2D Particle System/Motor2D/p2Point.h: -------------------------------------------------------------------------------- 1 | // ---------------------------------------------------- 2 | // Point class ----------- 3 | // ---------------------------------------------------- 4 | 5 | #ifndef __P2POINT_H__ 6 | #define __P2POINT_H__ 7 | 8 | #include "p2Defs.h" 9 | #include 10 | 11 | template 12 | class p2Point 13 | { 14 | public: 15 | 16 | TYPE x, y; 17 | 18 | p2Point() 19 | {} 20 | 21 | p2Point(const p2Point& v) 22 | { 23 | this->x = v.x; 24 | this->y = v.y; 25 | } 26 | 27 | p2Point(const TYPE& x, const TYPE& y) 28 | { 29 | this->x = x; 30 | this->y = y; 31 | } 32 | 33 | p2Point& create(const TYPE& x, const TYPE& y) 34 | { 35 | this->x = x; 36 | this->y = y; 37 | 38 | return(*this); 39 | } 40 | 41 | // Math ------------------------------------------------ 42 | p2Point operator -(const p2Point &v) const 43 | { 44 | p2Vector2 r; 45 | 46 | r.x = x - v.x; 47 | r.y = y - v.y; 48 | 49 | return(r); 50 | } 51 | 52 | p2Point operator + (const p2Point &v) const 53 | { 54 | p2Vector2 r; 55 | 56 | r.x = x + v.x; 57 | r.y = y + v.y; 58 | 59 | return(r); 60 | } 61 | 62 | const p2Point& operator -=(const p2Point &v) 63 | { 64 | x -= v.x; 65 | y -= v.y; 66 | 67 | return(*this); 68 | } 69 | 70 | const p2Point& operator +=(const p2Point &v) 71 | { 72 | x += v.x; 73 | y += v.y; 74 | 75 | return(*this); 76 | } 77 | 78 | bool operator ==(const p2Point& v) const 79 | { 80 | return (x == v.x && y == v.y); 81 | } 82 | 83 | bool operator !=(const p2Point& v) const 84 | { 85 | return (x != v.x || y != v.y); 86 | } 87 | 88 | // Utils ------------------------------------------------ 89 | bool IsZero() const 90 | { 91 | return (x == 0 && y == 0); 92 | } 93 | 94 | p2Point& SetToZero() 95 | { 96 | x = y = 0; 97 | return(*this); 98 | } 99 | 100 | p2Point& Negate() 101 | { 102 | x = -x; 103 | y = -y; 104 | 105 | return(*this); 106 | } 107 | 108 | // Distances --------------------------------------------- 109 | TYPE DistanceTo(const p2Point& v) const 110 | { 111 | TYPE fx = x - v.x; 112 | TYPE fy = y - v.y; 113 | 114 | return sqrtf((fx*fx) + (fy*fy)); 115 | } 116 | 117 | TYPE DistanceNoSqrt(const p2Point& v) const 118 | { 119 | TYPE fx = x - v.x; 120 | TYPE fy = y - v.y; 121 | 122 | return (fx*fx) + (fy*fy); 123 | } 124 | 125 | TYPE DistanceManhattan(const p2Point& v) const 126 | { 127 | return abs(v.x - x) + abs(v.y - y); 128 | } 129 | }; 130 | 131 | typedef p2Point iPoint; 132 | typedef p2Point fPoint; 133 | 134 | #endif // __P2POINT_H__ -------------------------------------------------------------------------------- /full_code/2D Particle System/Particle System.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2013 for Windows Desktop 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Motor 2D", "Motor2D\Motor2D.vcxproj", "{2AF9969B-F202-497B-AF30-7BEF9CE8005E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2AF9969B-F202-497B-AF30-7BEF9CE8005E}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {2AF9969B-F202-497B-AF30-7BEF9CE8005E}.Debug|Win32.Build.0 = Debug|Win32 16 | {2AF9969B-F202-497B-AF30-7BEF9CE8005E}.Release|Win32.ActiveCfg = Release|Win32 17 | {2AF9969B-F202-497B-AF30-7BEF9CE8005E}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | --------------------------------------------------------------------------------