├── GameData ├── Global │ ├── Font.ttf │ ├── ObjectBar.png │ ├── Sounds │ │ ├── ChasingSound.mp3 │ │ ├── CollisionSound.mp3 │ │ ├── Hurt.mp3 │ │ ├── TalkingNoise.mp3 │ │ └── WalkingSound.mp3 │ └── TextBar.png ├── Launch.conf ├── Saves │ ├── POS.sav │ ├── Script.sav │ └── TF.sav ├── Shaders │ ├── Lights │ │ ├── Lighting.fs │ │ └── Lighting.vs │ ├── Pixel.fs │ ├── Scanlines.fs │ ├── Sobel.fs │ └── Toon.fs └── Worlds │ └── World1 │ ├── Models │ ├── HeightMap.png │ ├── HeightMapConfig.conf │ ├── HeightMapTexture.png │ ├── Model2.obj │ ├── Model2Texture.png │ └── Skybox.png │ ├── Music │ └── Main.mp3 │ ├── NoiseEmitter │ └── NE1.mp3 │ ├── Scripts │ └── Launch.ps │ └── World.wdl ├── Makefile ├── README.md └── Source ├── Core.hpp ├── Custom ├── OTCustom.cpp └── OTCustom.hpp ├── Data.hpp ├── Editor.hpp ├── Encoder ├── Encoder.cpp └── Encoder.hpp ├── Entities.hpp ├── Main.cpp ├── Objects.hpp ├── PPGIO.hpp ├── Parasite ├── ParasiteScript.hpp └── ParasiteScriptData.hpp ├── ParticleDemon └── ParticleDemon.hpp ├── Player.hpp ├── Settings.hpp ├── TextSystem.hpp ├── Video.hpp ├── plmpeg └── pl_mpeg.h ├── raygui ├── dark.h ├── raygui.c └── raygui.h └── rlights └── rlights.h /GameData/Global/Font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paganswrath/OmegaTech/93c4b95ca634e2aae13e70b5990cf8a315c78660/GameData/Global/Font.ttf -------------------------------------------------------------------------------- /GameData/Global/ObjectBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paganswrath/OmegaTech/93c4b95ca634e2aae13e70b5990cf8a315c78660/GameData/Global/ObjectBar.png -------------------------------------------------------------------------------- /GameData/Global/Sounds/ChasingSound.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paganswrath/OmegaTech/93c4b95ca634e2aae13e70b5990cf8a315c78660/GameData/Global/Sounds/ChasingSound.mp3 -------------------------------------------------------------------------------- /GameData/Global/Sounds/CollisionSound.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paganswrath/OmegaTech/93c4b95ca634e2aae13e70b5990cf8a315c78660/GameData/Global/Sounds/CollisionSound.mp3 -------------------------------------------------------------------------------- /GameData/Global/Sounds/Hurt.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paganswrath/OmegaTech/93c4b95ca634e2aae13e70b5990cf8a315c78660/GameData/Global/Sounds/Hurt.mp3 -------------------------------------------------------------------------------- /GameData/Global/Sounds/TalkingNoise.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paganswrath/OmegaTech/93c4b95ca634e2aae13e70b5990cf8a315c78660/GameData/Global/Sounds/TalkingNoise.mp3 -------------------------------------------------------------------------------- /GameData/Global/Sounds/WalkingSound.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paganswrath/OmegaTech/93c4b95ca634e2aae13e70b5990cf8a315c78660/GameData/Global/Sounds/WalkingSound.mp3 -------------------------------------------------------------------------------- /GameData/Global/TextBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paganswrath/OmegaTech/93c4b95ca634e2aae13e70b5990cf8a315c78660/GameData/Global/TextBar.png -------------------------------------------------------------------------------- /GameData/Launch.conf: -------------------------------------------------------------------------------- 1 | 2: 2 | 3 | Config Info: 4 | 1st - Res Number 1 , 2 , 3 , 4 ,5 - 0 -------------------------------------------------------------------------------- /GameData/Saves/POS.sav: -------------------------------------------------------------------------------- 1 | 0.000000:0.000000:0.000000:1: -------------------------------------------------------------------------------- /GameData/Saves/Script.sav: -------------------------------------------------------------------------------- 1 | Script7:180.538818:6.750000:105.216690:5.000000:1.000000:Object2:181.495117:5.125000:105.846313:2.2:1.000000:Script7:180.538818:6.750000:105.216690:5.000000:1.000000:Object2:181.495117:5.125000:105.846313:2.2:1.000000:Script7:180.538818:6.750000:105.216690:5.000000:1.000000:Object2:181.495117:5.125000:105.846313:2.2:1.000000:Script7:180.538818:6.750000:105.216690:5.000000:1.000000:Object2:181.495117:5.125000:105.846313:2.2:1.000000:Script7:180.538818:6.750000:105.216690:5.000000:1.000000:Object2:181.495117:5.125000:105.846313:2.2:1.000000:Script7:180.538818:6.750000:105.216690:5.000000:1.000000:Object2:181.495117:5.125000:105.846313:2.2:1.000000:Script7:180.538818:6.750000:105.216690:5.000000:1.000000:Object2:181.495117:5.125000:105.846313:2.2:1.000000:Script7:180.538818:6.750000:105.216690:5.000000:1.000000:Object2:181.495117:5.125000:105.846313:2.2:1.000000:Script7:180.538818:6.750000:105.216690:5.000000:1.000000:Object2:181.495117:5.125000:105.846313:2.2:1.000000:Script7:180.538818:6.750000:105.216690:5.000000:1.000000:Object2:181.495117:5.125000:105.846313:2.2:1.000000: -------------------------------------------------------------------------------- /GameData/Saves/TF.sav: -------------------------------------------------------------------------------- 1 | 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000:00100 -------------------------------------------------------------------------------- /GameData/Shaders/Lights/Lighting.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec3 fragPosition; 5 | in vec2 fragTexCoord; 6 | //in vec4 fragColor; 7 | in vec3 fragNormal; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // Output fragment color 14 | out vec4 finalColor; 15 | 16 | // NOTE: Add here your custom variables 17 | 18 | #define MAX_LIGHTS 4 19 | #define LIGHT_DIRECTIONAL 0 20 | #define LIGHT_POINT 1 21 | 22 | struct MaterialProperty { 23 | vec3 color; 24 | int useSampler; 25 | sampler2D sampler; 26 | }; 27 | 28 | struct Light { 29 | int enabled; 30 | int type; 31 | vec3 position; 32 | vec3 target; 33 | vec4 color; 34 | }; 35 | 36 | // Input lighting values 37 | uniform Light lights[MAX_LIGHTS]; 38 | uniform vec4 ambient; 39 | uniform vec3 viewPos; 40 | 41 | void main() 42 | { 43 | // Texel color fetching from texture sampler 44 | vec4 texelColor = texture(texture0, fragTexCoord); 45 | vec3 lightDot = vec3(0.0); 46 | vec3 normal = normalize(fragNormal); 47 | vec3 viewD = normalize(viewPos - fragPosition); 48 | vec3 specular = vec3(0.0); 49 | 50 | // NOTE: Implement here your fragment shader code 51 | 52 | for (int i = 0; i < MAX_LIGHTS; i++) 53 | { 54 | if (lights[i].enabled == 1) 55 | { 56 | vec3 light = vec3(0.0); 57 | 58 | if (lights[i].type == LIGHT_DIRECTIONAL) 59 | { 60 | light = -normalize(lights[i].target - lights[i].position); 61 | } 62 | 63 | if (lights[i].type == LIGHT_POINT) 64 | { 65 | light = normalize(lights[i].position - fragPosition); 66 | } 67 | 68 | float NdotL = max(dot(normal, light), 0.0); 69 | lightDot += lights[i].color.rgb*NdotL; 70 | 71 | float specCo = 0.0; 72 | if (NdotL > 0.0) specCo = pow(max(0.0, dot(viewD, reflect(-(light), normal))), 16.0); // 16 refers to shine 73 | specular += specCo; 74 | } 75 | } 76 | 77 | finalColor = (texelColor*((colDiffuse + vec4(specular, 1.0))*vec4(lightDot, 1.0))); 78 | finalColor += texelColor*(ambient/10.0)*colDiffuse; 79 | 80 | // Gamma correction 81 | finalColor = pow(finalColor, vec4(1.0/2.2)); 82 | } 83 | -------------------------------------------------------------------------------- /GameData/Shaders/Lights/Lighting.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes 4 | in vec3 vertexPosition; 5 | in vec2 vertexTexCoord; 6 | in vec3 vertexNormal; 7 | in vec4 vertexColor; 8 | 9 | // Input uniform values 10 | uniform mat4 mvp; 11 | uniform mat4 matModel; 12 | uniform mat4 matNormal; 13 | 14 | // Output vertex attributes (to fragment shader) 15 | out vec3 fragPosition; 16 | out vec2 fragTexCoord; 17 | out vec4 fragColor; 18 | out vec3 fragNormal; 19 | 20 | // NOTE: Add here your custom variables 21 | 22 | void main() 23 | { 24 | // Send vertex attributes to fragment shader 25 | fragPosition = vec3(matModel*vec4(vertexPosition, 1.0)); 26 | fragTexCoord = vertexTexCoord; 27 | fragColor = vertexColor; 28 | fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0))); 29 | 30 | // Calculate final vertex position 31 | gl_Position = mvp*vec4(vertexPosition, 1.0); 32 | } 33 | -------------------------------------------------------------------------------- /GameData/Shaders/Pixel.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | 16 | // NOTE: Render size values must be passed from code 17 | const float renderWidth = 1280; 18 | const float renderHeight = 720; 19 | 20 | uniform float pixelWidth = 5.0; 21 | uniform float pixelHeight = 5.0; 22 | 23 | void main() 24 | { 25 | float dx = pixelWidth*(1.0/renderWidth); 26 | float dy = pixelHeight*(1.0/renderHeight); 27 | 28 | vec2 coord = vec2(dx*floor(fragTexCoord.x/dx), dy*floor(fragTexCoord.y/dy)); 29 | 30 | vec3 tc = texture(texture0, coord).rgb; 31 | 32 | finalColor = vec4(tc, 1.0); 33 | } -------------------------------------------------------------------------------- /GameData/Shaders/Scanlines.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | 16 | // NOTE: Render size values must be passed from code 17 | const float renderWidth = 1280; 18 | const float renderHeight = 720; 19 | float offset = 4.0; 20 | 21 | uniform float time; 22 | 23 | void main() 24 | { 25 | float frequency = renderHeight/3.0; 26 | /* 27 | // Scanlines method 1 28 | float tval = 0; //time 29 | vec2 uv = 0.5 + (fragTexCoord - 0.5)*(0.9 + 0.01*sin(0.5*tval)); 30 | 31 | vec4 color = texture(texture0, fragTexCoord); 32 | 33 | color = clamp(color*0.5 + 0.5*color*color*1.2, 0.0, 1.0); 34 | color *= 0.5 + 0.5*16.0*uv.x*uv.y*(1.0 - uv.x)*(1.0 - uv.y); 35 | color *= vec4(0.8, 1.0, 0.7, 1); 36 | color *= 0.9 + 0.1*sin(10.0*tval + uv.y*1000.0); 37 | color *= 0.97 + 0.03*sin(110.0*tval); 38 | 39 | fragColor = color; 40 | */ 41 | // Scanlines method 2 42 | float globalPos = (fragTexCoord.y + offset) * frequency; 43 | float wavePos = cos((fract(globalPos) - 0.5)*3.14); 44 | 45 | // Texel color fetching from texture sampler 46 | vec4 texelColor = texture(texture0, fragTexCoord); 47 | 48 | finalColor = mix(vec4(0.0, 0.3, 0.0, 0.0), texelColor, wavePos); 49 | } -------------------------------------------------------------------------------- /GameData/Shaders/Sobel.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec2 fragTexCoord; 4 | 5 | out vec4 fragColor; 6 | 7 | uniform sampler2D texture0; 8 | uniform vec4 colDiffuse; 9 | 10 | // NOTE: Add here your custom variables 11 | 12 | void main() 13 | { 14 | vec4 color = texture(texture0, fragTexCoord); 15 | 16 | color += texture(texture0, fragTexCoord + 0.001); 17 | color += texture(texture0, fragTexCoord + 0.003); 18 | color += texture(texture0, fragTexCoord + 0.005); 19 | color += texture(texture0, fragTexCoord + 0.007); 20 | color += texture(texture0, fragTexCoord + 0.009); 21 | color += texture(texture0, fragTexCoord + 0.011); 22 | 23 | color += texture(texture0, fragTexCoord - 0.001); 24 | color += texture(texture0, fragTexCoord - 0.003); 25 | color += texture(texture0, fragTexCoord - 0.005); 26 | color += texture(texture0, fragTexCoord - 0.007); 27 | color += texture(texture0, fragTexCoord - 0.009); 28 | color += texture(texture0, fragTexCoord - 0.011); 29 | 30 | color.rgb = vec3((color.r + color.g + color.b)/3.0); 31 | color = color/9.5; 32 | 33 | fragColor = color; 34 | } 35 | -------------------------------------------------------------------------------- /GameData/Shaders/Toon.fs: -------------------------------------------------------------------------------- 1 | uniform vec3 lightDir; 2 | varying vec3 normal; 3 | 4 | void main() 5 | { 6 | float intensity; 7 | vec4 color; 8 | intensity = dot(lightDir,normal); 9 | 10 | if (intensity > 0.95) 11 | color = vec4(1.0,0.5,0.5,1.0); 12 | else if (intensity > 0.5) 13 | color = vec4(0.6,0.3,0.3,1.0); 14 | else if (intensity > 0.25) 15 | color = vec4(0.4,0.2,0.2,1.0); 16 | else 17 | color = vec4(0.2,0.1,0.1,1.0); 18 | gl_FragColor = color; 19 | 20 | } -------------------------------------------------------------------------------- /GameData/Worlds/World1/Models/HeightMap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paganswrath/OmegaTech/93c4b95ca634e2aae13e70b5990cf8a315c78660/GameData/Worlds/World1/Models/HeightMap.png -------------------------------------------------------------------------------- /GameData/Worlds/World1/Models/HeightMapConfig.conf: -------------------------------------------------------------------------------- 1 | 200|32|200| -------------------------------------------------------------------------------- /GameData/Worlds/World1/Models/HeightMapTexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paganswrath/OmegaTech/93c4b95ca634e2aae13e70b5990cf8a315c78660/GameData/Worlds/World1/Models/HeightMapTexture.png -------------------------------------------------------------------------------- /GameData/Worlds/World1/Models/Model2Texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paganswrath/OmegaTech/93c4b95ca634e2aae13e70b5990cf8a315c78660/GameData/Worlds/World1/Models/Model2Texture.png -------------------------------------------------------------------------------- /GameData/Worlds/World1/Models/Skybox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paganswrath/OmegaTech/93c4b95ca634e2aae13e70b5990cf8a315c78660/GameData/Worlds/World1/Models/Skybox.png -------------------------------------------------------------------------------- /GameData/Worlds/World1/Music/Main.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paganswrath/OmegaTech/93c4b95ca634e2aae13e70b5990cf8a315c78660/GameData/Worlds/World1/Music/Main.mp3 -------------------------------------------------------------------------------- /GameData/Worlds/World1/NoiseEmitter/NE1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paganswrath/OmegaTech/93c4b95ca634e2aae13e70b5990cf8a315c78660/GameData/Worlds/World1/NoiseEmitter/NE1.mp3 -------------------------------------------------------------------------------- /GameData/Worlds/World1/Scripts/Launch.ps: -------------------------------------------------------------------------------- 1 | setcampos 100 10 100 2 | say Example World|/ -------------------------------------------------------------------------------- /GameData/Worlds/World1/World.wdl: -------------------------------------------------------------------------------- 1 | HeightMap:-120.0:-64.0:-100.0:4.0:0.0: -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | CFLAGS = -O3 --std=c++20 3 | LDFLAGS = -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 4 | COMP = g++ 5 | 6 | OBJS = raygui.o \ 7 | Encoder.o \ 8 | OTCustom.so \ 9 | Main.o 10 | 11 | COREHEADERS = Source/Core.hpp \ 12 | Encoder.o \ 13 | Main.o 14 | 15 | 16 | all: OTENGINE 17 | 18 | OTENGINE: $(OBJS) 19 | 20 | Main.o: Source/Main.cpp Source/*.hpp Source/Parasite/*.hpp 21 | $(COMP) $(CFLAGS) -c Source/Main.cpp $(LDFLAGS) 22 | 23 | # Compiles .so for Custom Engine Behavior 24 | 25 | OTCustom.so: Source/Custom/OTCustom.cpp 26 | $(COMP) $(CFLAGS) -c Source/Custom/OTCustom.cpp $(LDFLAGS) 27 | $(COMP) $(CFLAGS) -shared OTCustom.o -o Custom.so 28 | rm OTCustom.o 29 | 30 | 31 | Encoder.o: Source/Encoder/Encoder.cpp 32 | $(COMP) $(CFLAGS) -c Source/Encoder/Encoder.cpp $(LDFLAGS) 33 | 34 | raygui.o: Source/raygui/raygui.c 35 | $(COMP) $(CFLAGS) -c Source/raygui/raygui.c -shared -DRAYGUI_IMPLEMENTATION -DBUILD_LIBTYPE_SHARED -static-libgcc -lopengl32 -lgdi32 -lwinmm 36 | 37 | 38 | OTENGINE: 39 | $(COMP) *.o -o OmegaTech $(CFLAGS) $(LDFLAGS) -L. -l:Custom.so -Wl,-rpath=. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OmegaTech Engine 2 | 3 | Editor Here - > https://github.com/PixelPhobicGames/OTEditor 4 | 5 | Welcome to the OmegaTech Game Engine, a simple game engine inspired by the graphical style of the original PlayStation (PS1) console. This engine is built using the powerful and lightweight **raylib** library, providing a straightforward and efficient way to create retro-style games. 6 | 7 | ## Features 8 | 9 | - PS1-style graphics: Enjoy the nostalgic visuals reminiscent of the classic PlayStation console. 10 | - Sprite rendering: Display and animate sprites with ease. 11 | - Custom Level Format **(WDL - World Description Language.)** 12 | - Input handling: Capture and respond to user input, such as keyboard and gamepad controls. 13 | - Audio playback: Play sound effects and background music to enhance the gaming experience. 14 | - Simple API: Easy-to-use functions and structures for quick game development. 15 | - Incredibly Fast Graphics 16 | - Easy Portability 17 | - Video Playback 18 | - Custom Scripting Langauge 19 | 20 | ## Getting Started 21 | 22 | To use the OmegaTech Game Engine, follow these steps: 23 | 24 | 1. **Prerequisites**: Make sure you have the following installed on your system: 25 | - C++ compiler (GCC, Clang, or MSVC) 26 | - raylib library (version 4.5.0 or later) 27 | - Preferably a Linux System 28 | - [Download raylib](https://www.raylib.com/) and follow the installation instructions for your platform. 29 | 30 | 2. **Clone the repository**: Clone this GitHub repository to your local machine using the following command: 31 | 32 | ```shell 33 | clone https://github.com/PixelPhobicGames/OmegaTech/ 34 | ``` 35 | 36 | 3. **Build the engine**: Use your preferred C compiler to build the game engine. For example, with GCC, navigate to the project directory and run the following command: 37 | 38 | ```shell 39 | make 40 | ``` 41 | 42 | This command compiles the main source file (`main.c`) with raylib linked. 43 | 44 | 4. **Run the game**: After successfully building the engine, execute the game binary to launch the sample game: 45 | 46 | ```shell 47 | ./OmegaTech 48 | ``` 49 | 50 | 5. **Explore the code**: Open the project in your favorite text editor or integrated development environment (IDE) to explore and modify the source code according to your needs. 51 | 52 | 6. **Start developing**: Customize the game by modifying the source code. You can create new levels, implement game mechanics, and more. 53 | 7. **Note**: Make sure GameData Folder and Engine Executable are in the Same folder. 54 | 55 | ## Contributing 56 | 57 | Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue on the [GitHub repository](https://github.com/PixelPhobicGames/OmegaTech/issues). Feel free to submit pull requests with bug fixes, new features, or optimizations. 58 | 59 | 60 | ## License 61 | 62 | This project is licensed under the [MIT License](LICENSE). Feel free to use and modify the code according to the terms and conditions specified in the license. 63 | 64 | ## Acknowledgments 65 | 66 | The OmegaTech Game Engine was developed using the raylib library, which is an open-source project created by Ramon Santamaria. A huge thanks to Ramon and all the contributors for providing such a fantastic library for game development. 67 | 68 | Other Libraries 69 | https://github.com/WEREMSOFT/c99-raylib-vide-player 70 | https://github.com/phoboslab/pl_mpeg 71 | 72 | Special thanks to the PlayStation console, which served as the inspiration for the PS1-style graphics and aesthetics in this engine. 73 | 74 | ## Contact 75 | 76 | If you have any questions or suggestions related to the OmegaTech Game Engine, you can reach out to the project maintainer. 77 | -------------------------------------------------------------------------------- /Source/Core.hpp: -------------------------------------------------------------------------------- 1 | #include "Data.hpp" 2 | 3 | #include "raymath.h" 4 | #include "rlights/rlights.h" 5 | #include "Custom/OTCustom.hpp" 6 | 7 | bool FloorCollision = true; 8 | bool ObjectCollision = false; 9 | 10 | void LoadSave(); 11 | void SaveGame(); 12 | void UpdateCustom(); 13 | void CacheWDL(); 14 | void PutLight(Vector3 Position); 15 | void ClearLights(); 16 | 17 | class ParticleSystem; 18 | 19 | class EngineData 20 | { 21 | public: 22 | int LevelIndex = 1; 23 | Camera MainCamera = {0}; 24 | Shader PixelShader; 25 | Shader FogShader; 26 | Shader LineShader; 27 | Shader ToonShader; 28 | Shader SobelShader; 29 | Shader Lights; 30 | Light GameLights[MAX_LIGHTS]; 31 | 32 | ParticleSystem RainParticles; 33 | Texture HomeScreen; 34 | ray_video_t HomeScreenVideo; 35 | Music HomeScreenMusic; 36 | 37 | bool FirstLoad = true; 38 | 39 | int Ticker = 0; 40 | int CameraSpeed = 1; 41 | int RenderRadius = 800; 42 | int Deaths; 43 | bool UseCachedRenderer = false; 44 | int BadPreformaceCounter = 0; 45 | bool SkyboxEnabled = false; 46 | int Ending = 0; 47 | int PanicCounter = 0; 48 | 49 | void InitCamera() 50 | { 51 | MainCamera.position = (Vector3){0.0f, 0.0f, 0.0f}; 52 | MainCamera.target = (Vector3){0.0f, 10.0f, 0.0f}; 53 | MainCamera.up = (Vector3){0.0f, 1.0f, 0.0f}; 54 | MainCamera.fovy = 60.0f; 55 | MainCamera.projection = CAMERA_PERSPECTIVE; 56 | } 57 | }; 58 | 59 | static EngineData OmegaTechData; 60 | 61 | void SpawnWDLProcess(const char *Path) 62 | { 63 | wstring WData; 64 | 65 | if (GameDataEncoded) 66 | { 67 | WData = Encode(LoadFile(Path), MainKey); 68 | } 69 | else 70 | { 71 | WData = LoadFile(Path); 72 | } 73 | 74 | int WDLSize = 0; 75 | 76 | for (int i = 0; i <= WData.size(); i++) 77 | { 78 | if (WData[i] == L':') 79 | { 80 | WDLSize++; 81 | } 82 | } 83 | 84 | int EntityCounter = 0; 85 | 86 | for (int i = 0; i <= WDLSize; i++) 87 | { 88 | wstring Instruction = WSplitValue(WData, i); 89 | 90 | if (WReadValue(Instruction, 0, 5) == L"Walker") 91 | { 92 | OmegaEnemy[EntityCounter].X = ToFloat(WSplitValue(WData, i + 1)); 93 | OmegaEnemy[EntityCounter].Y = ToFloat(WSplitValue(WData, i + 2)); 94 | OmegaEnemy[EntityCounter].Z = ToFloat(WSplitValue(WData, i + 3)); 95 | OmegaEnemy[EntityCounter].IsActive = true; 96 | OmegaEnemy[EntityCounter].Scream = false; 97 | EntityCounter++; 98 | } 99 | 100 | if (Instruction == L"Light") 101 | { 102 | PutLight({ToFloat(WSplitValue(WData, i + 1)) , ToFloat(WSplitValue(WData, i + 2)) , ToFloat(WSplitValue(WData, i + 3))}); 103 | } 104 | 105 | i += 3; 106 | } 107 | } 108 | 109 | bool LoadFlag = false; 110 | 111 | auto LoadWorld() 112 | { 113 | PlayFade(); 114 | ClearLights(); 115 | 116 | 117 | if (OmegaTechData.Deaths != 3) 118 | { 119 | 120 | OmegaTechData.PanicCounter = 0; 121 | 122 | OmegaPlayer.Health = 100; 123 | 124 | OmegaTechData.SkyboxEnabled = false; 125 | 126 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/NoiseEmitter/NE1.mp3", OmegaTechData.LevelIndex))) 127 | { 128 | StopMusicStream(OmegaTechSoundData.NESound1); 129 | OmegaTechSoundData.NESound1 = LoadMusicStream(TextFormat("GameData/Worlds/World%i/NoiseEmitter/NE1.mp3", OmegaTechData.LevelIndex)); 130 | } 131 | else { 132 | UnloadMusicStream(OmegaTechSoundData.NESound1); 133 | } 134 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/NoiseEmitter/NE2.mp3", OmegaTechData.LevelIndex))) 135 | { 136 | StopMusicStream(OmegaTechSoundData.NESound2); 137 | OmegaTechSoundData.NESound2 = LoadMusicStream(TextFormat("GameData/Worlds/World%i/NoiseEmitter/NE2.mp3", OmegaTechData.LevelIndex)); 138 | } 139 | else { 140 | UnloadMusicStream(OmegaTechSoundData.NESound2); 141 | } 142 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/NoiseEmitter/NE3.mp3", OmegaTechData.LevelIndex))) 143 | { 144 | StopMusicStream(OmegaTechSoundData.NESound3); 145 | OmegaTechSoundData.NESound3 = LoadMusicStream(TextFormat("GameData/Worlds/World%i/NoiseEmitter/NE3.mp3", OmegaTechData.LevelIndex)); 146 | } 147 | else { 148 | UnloadMusicStream(OmegaTechSoundData.NESound3); 149 | } 150 | 151 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Skybox.png", OmegaTechData.LevelIndex))) 152 | { 153 | 154 | WDLModels.Skybox = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Skybox.png", OmegaTechData.LevelIndex)); 155 | OmegaTechData.SkyboxEnabled = true; 156 | } 157 | 158 | for (int i = 0; i <= EntityCount - 1; i++) 159 | { 160 | OmegaEnemy[i].IsActive = false; 161 | OmegaEnemy[i].Scream = false; 162 | } 163 | 164 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Scripts/Launch.ps", OmegaTechData.LevelIndex))) 165 | { 166 | ParasiteScriptInit(); 167 | LoadScript(TextFormat("GameData/Worlds/World%i/Scripts/Launch.ps", OmegaTechData.LevelIndex)); 168 | for (int x = 0; x <= ParasiteScriptCoreData.ProgramSize; x++) 169 | { 170 | CycleInstruction(); 171 | ParasiteScriptCoreData.LineCounter++; 172 | } 173 | } 174 | 175 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Entities/Walker/Frame1.png", OmegaTechData.LevelIndex))) 176 | { 177 | EnemyTextures.Frame1 = LoadTexture(TextFormat("GameData/Worlds/World%i/Entities/Walker/Frame1.png", OmegaTechData.LevelIndex)); 178 | EnemyTextures.Scream = LoadSound(TextFormat("GameData/Worlds/World%i/Entities/Walker/Scream.mp3", OmegaTechData.LevelIndex)); 179 | SpawnWDLProcess(TextFormat("GameData/Worlds/World%i/Entities/Entities.wdl", OmegaTechData.LevelIndex)); 180 | } 181 | 182 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/HeightMap.png", OmegaTechData.LevelIndex))) 183 | { 184 | WDLModels.HeightMapTexture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/HeightMapTexture.png", OmegaTechData.LevelIndex)); 185 | Image HeightMapImage = LoadImage(TextFormat("GameData/Worlds/World%i/Models/HeightMap.png", OmegaTechData.LevelIndex)); 186 | Texture2D Texture = LoadTextureFromImage(HeightMapImage); 187 | int X = PullConfigValue(TextFormat("GameData/Worlds/World%i/Models/HeightMapConfig.conf", OmegaTechData.LevelIndex), 0); 188 | int Y = PullConfigValue(TextFormat("GameData/Worlds/World%i/Models/HeightMapConfig.conf", OmegaTechData.LevelIndex), 1); 189 | int Z = PullConfigValue(TextFormat("GameData/Worlds/World%i/Models/HeightMapConfig.conf", OmegaTechData.LevelIndex), 2); 190 | Mesh Mesh1 = GenMeshHeightmap(HeightMapImage, (Vector3){X, Y, Z}); 191 | WDLModels.HeightMap = LoadModelFromMesh(Mesh1); 192 | WDLModels.HeightMap.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.HeightMapTexture; 193 | WDLModels.HeightMap.meshes[0] = Mesh1; 194 | WDLModels.HeightMap.materials[0].shader = OmegaTechData.Lights; 195 | } 196 | 197 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model1.obj", OmegaTechData.LevelIndex))) 198 | { 199 | WDLModels.Model1 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model1.obj", OmegaTechData.LevelIndex)); 200 | WDLModels.Model1Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model1Texture.png", OmegaTechData.LevelIndex)); 201 | WDLModels.Model1.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model1Texture; 202 | WDLModels.Model1.materials[0].shader = OmegaTechData.Lights; 203 | } 204 | else { 205 | if (WDLModels.Model1.meshCount != 0){ 206 | UnloadModel(WDLModels.Model1); 207 | } 208 | if (WDLModels.Model1Texture.id != 0){ 209 | UnloadTexture(WDLModels.Model1Texture); 210 | } 211 | } 212 | 213 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model2.obj", OmegaTechData.LevelIndex))) 214 | { 215 | WDLModels.Model2 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model2.obj", OmegaTechData.LevelIndex)); 216 | WDLModels.Model2Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model2Texture.png", OmegaTechData.LevelIndex)); 217 | WDLModels.Model2.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model2Texture; 218 | WDLModels.Model2.materials[0].shader = OmegaTechData.Lights; 219 | } 220 | else { 221 | if (WDLModels.Model2.meshCount != 0){ 222 | UnloadModel(WDLModels.Model2); 223 | } 224 | if (WDLModels.Model2Texture.id != 0){ 225 | UnloadTexture(WDLModels.Model2Texture); 226 | } 227 | } 228 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model3.obj", OmegaTechData.LevelIndex))) 229 | { 230 | WDLModels.Model3 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model3.obj", OmegaTechData.LevelIndex)); 231 | WDLModels.Model3Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model3Texture.png", OmegaTechData.LevelIndex)); 232 | WDLModels.Model3.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model3Texture; 233 | WDLModels.Model3.materials[0].shader = OmegaTechData.Lights; 234 | } 235 | else { 236 | if (WDLModels.Model3.meshCount != 0){ 237 | UnloadModel(WDLModels.Model13); 238 | } 239 | if (WDLModels.Model3Texture.id != 0){ 240 | UnloadTexture(WDLModels.Model3Texture); 241 | } 242 | } 243 | 244 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model4.obj", OmegaTechData.LevelIndex))) 245 | { 246 | WDLModels.Model4 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model4.obj", OmegaTechData.LevelIndex)); 247 | WDLModels.Model4Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model4Texture.png", OmegaTechData.LevelIndex)); 248 | WDLModels.Model4.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model4Texture; 249 | WDLModels.Model4.materials[0].shader = OmegaTechData.Lights; 250 | } 251 | else { 252 | if (WDLModels.Model4.meshCount != 0){ 253 | UnloadModel(WDLModels.Model4); 254 | } 255 | if (WDLModels.Model4Texture.id != 0){ 256 | UnloadTexture(WDLModels.Model4Texture); 257 | } 258 | } 259 | 260 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model5.obj", OmegaTechData.LevelIndex))) 261 | { 262 | WDLModels.Model5 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model5.obj", OmegaTechData.LevelIndex)); 263 | WDLModels.Model5Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model5Texture.png", OmegaTechData.LevelIndex)); 264 | WDLModels.Model5.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model5Texture; 265 | WDLModels.Model5.materials[0].shader = OmegaTechData.Lights; 266 | } 267 | else { 268 | if (WDLModels.Model5.meshCount != 0){ 269 | UnloadModel(WDLModels.Model5); 270 | } 271 | if (WDLModels.Model5Texture.id != 0){ 272 | UnloadTexture(WDLModels.Model5Texture); 273 | } 274 | } 275 | 276 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model6.obj", OmegaTechData.LevelIndex))) 277 | { 278 | WDLModels.Model6 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model6.obj", OmegaTechData.LevelIndex)); 279 | WDLModels.Model6Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model6Texture.png", OmegaTechData.LevelIndex)); 280 | WDLModels.Model6.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model6Texture; 281 | WDLModels.Model6.materials[0].shader = OmegaTechData.Lights; 282 | } 283 | else { 284 | if (WDLModels.Model6.meshCount != 0){ 285 | UnloadModel(WDLModels.Model6); 286 | } 287 | if (WDLModels.Model6Texture.id != 0){ 288 | UnloadTexture(WDLModels.Model6Texture); 289 | } 290 | } 291 | 292 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model7.obj", OmegaTechData.LevelIndex))) 293 | { 294 | WDLModels.Model7 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model7.obj", OmegaTechData.LevelIndex)); 295 | WDLModels.Model7Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model7Texture.png", OmegaTechData.LevelIndex)); 296 | WDLModels.Model7.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model7Texture; 297 | WDLModels.Model7.materials[0].shader = OmegaTechData.Lights; 298 | 299 | } 300 | else { 301 | if (WDLModels.Model7.meshCount != 0){ 302 | UnloadModel(WDLModels.Model7); 303 | } 304 | if (WDLModels.Model7Texture.id != 0){ 305 | UnloadTexture(WDLModels.Model7Texture); 306 | } 307 | } 308 | 309 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model8.obj", OmegaTechData.LevelIndex))) 310 | { 311 | WDLModels.Model8 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model8.obj", OmegaTechData.LevelIndex)); 312 | WDLModels.Model8Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model8Texture.png", OmegaTechData.LevelIndex)); 313 | WDLModels.Model8.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model8Texture; 314 | WDLModels.Model8.materials[0].shader = OmegaTechData.Lights; 315 | 316 | } 317 | else { 318 | if (WDLModels.Model8.meshCount != 0){ 319 | UnloadModel(WDLModels.Model8); 320 | } 321 | if (WDLModels.Model8Texture.id != 0){ 322 | UnloadTexture(WDLModels.Model8Texture); 323 | } 324 | } 325 | 326 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model9.obj", OmegaTechData.LevelIndex))) 327 | { 328 | WDLModels.Model9 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model9.obj", OmegaTechData.LevelIndex)); 329 | WDLModels.Model9Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model9Texture.png", OmegaTechData.LevelIndex)); 330 | WDLModels.Model9.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model9Texture; 331 | WDLModels.Model9.materials[0].shader = OmegaTechData.Lights; 332 | 333 | } 334 | else { 335 | if (WDLModels.Model9.meshCount != 0){ 336 | UnloadModel(WDLModels.Model9); 337 | } 338 | if (WDLModels.Model9Texture.id != 0){ 339 | UnloadTexture(WDLModels.Model9Texture); 340 | } 341 | } 342 | 343 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model10.obj", OmegaTechData.LevelIndex))) 344 | { 345 | WDLModels.Model10 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model10.obj", OmegaTechData.LevelIndex)); 346 | WDLModels.Model10Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model10Texture.png", OmegaTechData.LevelIndex)); 347 | WDLModels.Model10.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model10Texture; 348 | WDLModels.Model10.materials[0].shader = OmegaTechData.Lights; 349 | 350 | } 351 | else { 352 | if (WDLModels.Model10.meshCount != 0){ 353 | UnloadModel(WDLModels.Model10); 354 | } 355 | if (WDLModels.Model10Texture.id != 0){ 356 | UnloadTexture(WDLModels.Model10Texture); 357 | } 358 | } 359 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model11.obj", OmegaTechData.LevelIndex))) 360 | { 361 | WDLModels.Model11 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model11.obj", OmegaTechData.LevelIndex)); 362 | WDLModels.Model11Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model11Texture.png", OmegaTechData.LevelIndex)); 363 | WDLModels.Model11.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model11Texture; 364 | WDLModels.Model11.materials[0].shader = OmegaTechData.Lights; 365 | 366 | } 367 | else { 368 | if (WDLModels.Model11.meshCount != 0){ 369 | UnloadModel(WDLModels.Model11); 370 | } 371 | if (WDLModels.Model11Texture.id != 0){ 372 | UnloadTexture(WDLModels.Model11Texture); 373 | } 374 | } 375 | 376 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model12.obj", OmegaTechData.LevelIndex))) 377 | { 378 | WDLModels.Model12 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model12.obj", OmegaTechData.LevelIndex)); 379 | WDLModels.Model12Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model12Texture.png", OmegaTechData.LevelIndex)); 380 | WDLModels.Model12.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model12Texture; 381 | WDLModels.Model12.materials[0].shader = OmegaTechData.Lights; 382 | 383 | } 384 | else { 385 | if (WDLModels.Model12.meshCount != 0){ 386 | UnloadModel(WDLModels.Model12); 387 | } 388 | if (WDLModels.Model12Texture.id != 0){ 389 | UnloadTexture(WDLModels.Model12Texture); 390 | } 391 | } 392 | 393 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model13.obj", OmegaTechData.LevelIndex))) 394 | { 395 | WDLModels.Model13 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model13.obj", OmegaTechData.LevelIndex)); 396 | WDLModels.Model13Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model13Texture.png", OmegaTechData.LevelIndex)); 397 | WDLModels.Model13.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model13Texture; 398 | WDLModels.Model13.materials[0].shader = OmegaTechData.Lights; 399 | 400 | } 401 | else { 402 | if (WDLModels.Model13.meshCount != 0){ 403 | UnloadModel(WDLModels.Model13); 404 | } 405 | if (WDLModels.Model13Texture.id != 0){ 406 | UnloadTexture(WDLModels.Model13Texture); 407 | } 408 | } 409 | 410 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model14.obj", OmegaTechData.LevelIndex))) 411 | { 412 | WDLModels.Model14 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model14.obj", OmegaTechData.LevelIndex)); 413 | WDLModels.Model14Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model14Texture.png", OmegaTechData.LevelIndex)); 414 | WDLModels.Model14.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model14Texture; 415 | WDLModels.Model14.materials[0].shader = OmegaTechData.Lights; 416 | 417 | } 418 | else { 419 | if (WDLModels.Model14.meshCount != 0){ 420 | UnloadModel(WDLModels.Model14); 421 | } 422 | if (WDLModels.Model14Texture.id != 0){ 423 | UnloadTexture(WDLModels.Model14Texture); 424 | } 425 | } 426 | 427 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model15.obj", OmegaTechData.LevelIndex))) 428 | { 429 | WDLModels.Model15 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model15.obj", OmegaTechData.LevelIndex)); 430 | WDLModels.Model15Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model15Texture.png", OmegaTechData.LevelIndex)); 431 | WDLModels.Model15.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model15Texture; 432 | WDLModels.Model15.materials[0].shader = OmegaTechData.Lights; 433 | 434 | } 435 | else { 436 | if (WDLModels.Model15.meshCount != 0){ 437 | UnloadModel(WDLModels.Model15); 438 | } 439 | if (WDLModels.Model15Texture.id != 0){ 440 | UnloadTexture(WDLModels.Model15Texture); 441 | } 442 | } 443 | 444 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model16.obj", OmegaTechData.LevelIndex))) 445 | { 446 | WDLModels.Model16 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model16.obj", OmegaTechData.LevelIndex)); 447 | WDLModels.Model16Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model16Texture.png", OmegaTechData.LevelIndex)); 448 | WDLModels.Model16.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model16Texture; 449 | WDLModels.Model16.materials[0].shader = OmegaTechData.Lights; 450 | 451 | } 452 | else { 453 | if (WDLModels.Model16.meshCount != 0){ 454 | UnloadModel(WDLModels.Model16); 455 | } 456 | if (WDLModels.Model16Texture.id != 0){ 457 | UnloadTexture(WDLModels.Model16Texture); 458 | } 459 | } 460 | 461 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model17.obj", OmegaTechData.LevelIndex))) 462 | { 463 | WDLModels.Model17 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model17.obj", OmegaTechData.LevelIndex)); 464 | WDLModels.Model17Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model17Texture.png", OmegaTechData.LevelIndex)); 465 | WDLModels.Model17.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model17Texture; 466 | WDLModels.Model17.materials[0].shader = OmegaTechData.Lights; 467 | 468 | } 469 | else { 470 | if (WDLModels.Model17.meshCount != 0){ 471 | UnloadModel(WDLModels.Model17); 472 | } 473 | if (WDLModels.Model17Texture.id != 0){ 474 | UnloadTexture(WDLModels.Model17Texture); 475 | } 476 | } 477 | 478 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model18.obj", OmegaTechData.LevelIndex))) 479 | { 480 | WDLModels.Model18 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model18.obj", OmegaTechData.LevelIndex)); 481 | WDLModels.Model18Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model18Texture.png", OmegaTechData.LevelIndex)); 482 | WDLModels.Model18.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model18Texture; 483 | WDLModels.Model18.materials[0].shader = OmegaTechData.Lights; 484 | 485 | } 486 | else { 487 | if (WDLModels.Model18.meshCount != 0){ 488 | UnloadModel(WDLModels.Model18); 489 | } 490 | if (WDLModels.Model18Texture.id != 0){ 491 | UnloadTexture(WDLModels.Model18Texture); 492 | } 493 | } 494 | 495 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model19.obj", OmegaTechData.LevelIndex))) 496 | { 497 | WDLModels.Model19 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model19.obj", OmegaTechData.LevelIndex)); 498 | WDLModels.Model19Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model19Texture.png", OmegaTechData.LevelIndex)); 499 | WDLModels.Model19.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model19Texture; 500 | WDLModels.Model19.materials[0].shader = OmegaTechData.Lights; 501 | 502 | } 503 | else { 504 | if (WDLModels.Model19.meshCount != 0){ 505 | UnloadModel(WDLModels.Model19); 506 | } 507 | if (WDLModels.Model19Texture.id != 0){ 508 | UnloadTexture(WDLModels.Model19Texture); 509 | } 510 | } 511 | 512 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Models/Model20.obj", OmegaTechData.LevelIndex))) 513 | { 514 | WDLModels.Model20 = LoadModel(TextFormat("GameData/Worlds/World%i/Models/Model20.obj", OmegaTechData.LevelIndex)); 515 | WDLModels.Model20Texture = LoadTexture(TextFormat("GameData/Worlds/World%i/Models/Model20Texture.png", OmegaTechData.LevelIndex)); 516 | WDLModels.Model20.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.Model20Texture; 517 | WDLModels.Model20.materials[0].shader = OmegaTechData.Lights; 518 | 519 | } 520 | else { 521 | if (WDLModels.Model20.meshCount != 0){ 522 | UnloadModel(WDLModels.Model20); 523 | } 524 | if (WDLModels.Model20Texture.id != 0){ 525 | UnloadTexture(WDLModels.Model20Texture); 526 | } 527 | } 528 | 529 | if (GameDataEncoded) 530 | { 531 | WorldData = Encode(LoadFile(TextFormat("GameData/Worlds/World%i/World.wdl", OmegaTechData.LevelIndex)), MainKey); 532 | } 533 | else 534 | { 535 | WorldData = L""; 536 | WorldData = LoadFile(TextFormat("GameData/Worlds/World%i/World.wdl", OmegaTechData.LevelIndex)); 537 | OtherWDLData = L""; 538 | CacheWDL(); 539 | } 540 | 541 | if (OmegaTechSoundData.MusicFound)StopMusicStream(OmegaTechSoundData.BackgroundMusic); 542 | 543 | OmegaTechSoundData.MusicFound = false; 544 | 545 | if (IsPathFile(TextFormat("GameData/Worlds/World%i/Music/Main.mp3", OmegaTechData.LevelIndex))) 546 | { 547 | OmegaTechSoundData.BackgroundMusic = LoadMusicStream(TextFormat("GameData/Worlds/World%i/Music/Main.mp3", OmegaTechData.LevelIndex)); 548 | OmegaTechSoundData.MusicFound = true; 549 | PlayMusicStream(OmegaTechSoundData.BackgroundMusic); 550 | } 551 | 552 | SaveGame(); 553 | } 554 | } 555 | 556 | void LoadLaunchConfig() 557 | { 558 | wstring Config = LoadFile("GameData/Launch.conf"); 559 | 560 | wstring Resolution = WSplitValue(Config, 0); 561 | 562 | switch (Resolution[0]) 563 | { 564 | case L'1': 565 | SetWindowSize(640, 480); 566 | break; 567 | case L'2': 568 | SetWindowSize(1280, 720); 569 | break; 570 | case L'3': 571 | SetWindowSize(1980, 1080); 572 | break; 573 | case L'4': 574 | SetWindowSize(2560, 1440); 575 | break; 576 | case L'5': 577 | SetWindowSize(3840, 2160); 578 | break; 579 | default: 580 | SetWindowSize(GetMonitorWidth(0), GetMonitorHeight(0)); 581 | ToggleFullscreen(); 582 | break; 583 | } 584 | } 585 | 586 | int LightCounter = 1; 587 | 588 | void UpdateLightSources(){ 589 | float cameraPos[3] = { OmegaTechData.MainCamera.position.x, OmegaTechData.MainCamera.position.y, OmegaTechData.MainCamera.position.z }; 590 | OmegaTechData.GameLights[0].position = { OmegaTechData.MainCamera.position.x, OmegaTechData.MainCamera.position.y, OmegaTechData.MainCamera.position.z }; 591 | OmegaTechData.GameLights[0].target = { OmegaTechData.MainCamera.target.x, OmegaTechData.MainCamera.target.y - 5, OmegaTechData.MainCamera.target.z }; 592 | SetShaderValue(OmegaTechData.Lights, OmegaTechData.Lights.locs[SHADER_LOC_VECTOR_VIEW], cameraPos, SHADER_UNIFORM_VEC3); 593 | for (int i = 0; i < MAX_LIGHTS - 1; i++) UpdateLightValues(OmegaTechData.Lights, OmegaTechData.GameLights[i]); 594 | } 595 | 596 | void ClearLights(){ 597 | LightCounter = 1; 598 | OmegaTechData.GameLights[MAX_LIGHTS] = { 0 }; 599 | } 600 | 601 | void PutLight(Vector3 Position){ 602 | OmegaTechData.GameLights[LightCounter] = CreateLight(LIGHT_POINT, Position, Vector3Zero(), RED, OmegaTechData.Lights); 603 | LightCounter ++; 604 | } 605 | 606 | void DrawLights(){ 607 | for (int i = 1; i < MAX_LIGHTS; i++) 608 | { 609 | if (OmegaTechData.GameLights[i].enabled) DrawSphereEx(OmegaTechData.GameLights[i].position, 0.2f, 8, 8, OmegaTechData.GameLights[i].color); 610 | else DrawSphereWires(OmegaTechData.GameLights[i].position, 0.2f, 8, 8, ColorAlpha(OmegaTechData.GameLights[i].color, 0.3f)); 611 | } 612 | } 613 | 614 | void OmegaTechInit() 615 | { 616 | LoadLaunchConfig(); 617 | ParasiteScriptTFlagWipe(); 618 | 619 | GuiLoadStyleDark(); 620 | 621 | OmegaTechData.InitCamera(); 622 | 623 | OmegaTechData.PixelShader = LoadShader(0, "GameData/Shaders/Pixel.fs"); 624 | OmegaTechData.FogShader = LoadShader(0, "GameData/Shaders/Fog.fs"); 625 | OmegaTechData.LineShader = LoadShader(0, "GameData/Shaders/Scanlines.fs"); 626 | OmegaTechData.SobelShader = LoadShader(0, "GameData/Shaders/Sobel.fs"); 627 | OmegaTechData.ToonShader = LoadShader(0, "GameData/Shaders/Toon.fs"); 628 | OmegaTechData.Lights = LoadShader("GameData/Shaders/Lights/Lighting.vs","GameData/Shaders/Lights/Lighting.fs"); 629 | OmegaTechData.GameLights[MAX_LIGHTS] = { 0 }; 630 | 631 | 632 | OmegaTechData.Lights.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(OmegaTechData.Lights, "viewPos"); 633 | int AmbientLoc = GetShaderLocation(OmegaTechData.Lights, "ambient"); 634 | float ambient[4] = { 0.1f, 0.1f, 0.1f, 1.0f }; 635 | SetShaderValue(OmegaTechData.Lights, AmbientLoc, ambient, SHADER_UNIFORM_VEC4); 636 | 637 | 638 | if (IsPathFile("GameData/Global/Title/Title.png"))OmegaTechData.HomeScreen = LoadTexture("GameData/Global/Title/Title.png"); 639 | if (IsPathFile("GameData/Global/Title/Title.mpg"))OmegaTechData.HomeScreenVideo = ray_video_open("GameData/Global/Title/Title.mpg"); 640 | if (IsPathFile("GameData/Global/Title/Title.mp3"))OmegaTechData.HomeScreenMusic = LoadMusicStream("GameData/Global/Title/Title.mp3"); 641 | 642 | OmegaTechTextSystem.Bar = LoadTexture("GameData/Global/TextBar.png"); 643 | OmegaTechTextSystem.BarFont = LoadFont("GameData/Global/Font.ttf"); 644 | OmegaTechSoundData.CollisionSound = LoadSound("GameData/Global/Sounds/CollisionSound.mp3"); 645 | OmegaTechSoundData.WalkingSound = LoadSound("GameData/Global/Sounds/WalkingSound.mp3"); 646 | OmegaTechSoundData.ChasingSound = LoadSound("GameData/Global/Sounds/ChasingSound.mp3"); 647 | OmegaTechSoundData.UIClick = LoadSound("GameData/Global/Title/Click.mp3"); 648 | OmegaTechSoundData.Death = LoadSound("GameData/Global/Sounds/Hurt.mp3"); 649 | 650 | OmegaTechTextSystem.TextNoise = LoadSound("GameData/Global/Sounds/TalkingNoise.mp3"); 651 | 652 | if (IsPathFile("GameData/Global/FModels/FModel1.gltf")) 653 | { 654 | WDLModels.FastModel1 = LoadModel("GameData/Global/FModels/FModel1.gltf"); 655 | WDLModels.FastModel1Texture = LoadTexture("GameData/Global/FModels/FModel1Texture.png"); 656 | WDLModels.FastModel1.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.FastModel1Texture; 657 | WDLModels.FastModel1.materials[0].shader = OmegaTechData.Lights; 658 | } 659 | if (IsPathFile("GameData/Global/FModels/FModel2.gltf")) 660 | { 661 | WDLModels.FastModel2 = LoadModel("GameData/Global/FModels/FModel2.gltf"); 662 | WDLModels.FastModel2Texture = LoadTexture("GameData/Global/FModels/FModel2Texture.png"); 663 | WDLModels.FastModel2.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.FastModel2Texture; 664 | WDLModels.FastModel2.materials[0].shader = OmegaTechData.Lights; 665 | } 666 | if (IsPathFile("GameData/Global/FModels/FModel3.gltf")) 667 | { 668 | WDLModels.FastModel3 = LoadModel("GameData/Global/FModels/FModel3.gltf"); 669 | WDLModels.FastModel3Texture = LoadTexture("GameData/Global/FModels/FModel3Texture.png"); 670 | WDLModels.FastModel3.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.FastModel3Texture; 671 | WDLModels.FastModel3.materials[0].shader = OmegaTechData.Lights; 672 | } 673 | if (IsPathFile("GameData/Global/FModels/FModel4.gltf")) 674 | { 675 | WDLModels.FastModel4 = LoadModel("GameData/Global/FModels/FModel4.gltf"); 676 | WDLModels.FastModel4Texture = LoadTexture("GameData/Global/FModels/FModel4Texture.png"); 677 | WDLModels.FastModel4.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.FastModel4Texture; 678 | WDLModels.FastModel4.materials[0].shader = OmegaTechData.Lights; 679 | } 680 | if (IsPathFile("GameData/Global/FModels/FModel5.gltf")) 681 | { 682 | WDLModels.FastModel5 = LoadModel("GameData/Global/FModels/FModel5.gltf"); 683 | WDLModels.FastModel5Texture = LoadTexture("GameData/Global/FModels/FModel5Texture.png"); 684 | WDLModels.FastModel5.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = WDLModels.FastModel5Texture; 685 | WDLModels.FastModel5.materials[0].shader = OmegaTechData.Lights; 686 | } 687 | 688 | OmegaTechData.GameLights[0] = CreateLight(LIGHT_DIRECTIONAL, { OmegaTechData.MainCamera.position.x, OmegaTechData.MainCamera.position.y, OmegaTechData.MainCamera.position.z }, Vector3Zero(), WHITE, OmegaTechData.Lights); 689 | 690 | Target = LoadRenderTexture(GetScreenWidth(), GetScreenHeight()); 691 | 692 | InitObjects(); 693 | 694 | PlayMusicStream(OmegaTechData.HomeScreenMusic); 695 | } 696 | 697 | void PlayHomeScreen() 698 | { 699 | Rectangle LayoutRecs[5] = { 700 | (Rectangle){583, 355, 120, 24}, 701 | (Rectangle){583, 421, 120, 24}, 702 | (Rectangle){583, 387, 120, 24}, 703 | (Rectangle){583, 489, 120, 24}, 704 | (Rectangle){583, 454, 120, 24}, 705 | }; 706 | 707 | while (true && !WindowShouldClose()) 708 | { 709 | BeginTextureMode(Target); 710 | UpdateMusicStream(OmegaTechData.HomeScreenMusic); 711 | 712 | ClearBackground(BLACK); 713 | 714 | if (IsPathFile("GameData/Global/Title/Title.mpg"))ray_video_update(&OmegaTechData.HomeScreenVideo, GetFrameTime()); 715 | 716 | DrawTextureEx(OmegaTechData.HomeScreenVideo.texture, {0, 0}, 0, 5, WHITE); 717 | DrawTexture(OmegaTechData.HomeScreen, 0, 0, WHITE); 718 | 719 | if (OmegaInputController.InteractPressed) 720 | { 721 | PlaySound(OmegaTechSoundData.UIClick); 722 | } 723 | 724 | if (GuiButton(LayoutRecs[0], "Start New Game")) 725 | { 726 | UnloadRenderTexture(Target); 727 | Target = LoadRenderTexture(GetScreenWidth() / 4, GetScreenHeight() / 4); 728 | 729 | break; 730 | } 731 | 732 | if (GuiButton(LayoutRecs[1], "Load Save")) 733 | { 734 | UnloadRenderTexture(Target); 735 | Target = LoadRenderTexture(320 , 240); 736 | 737 | if (IsPathFile("GameData/Saves/TF.sav")) 738 | { 739 | LoadSave(); 740 | LoadFlag = true; 741 | } 742 | break; 743 | } 744 | 745 | GuiLine(LayoutRecs[2], NULL); 746 | 747 | if (GuiButton(LayoutRecs[3], "Settings")) 748 | { 749 | if (MenuSettings) 750 | { 751 | MenuSettings = false; 752 | } 753 | else 754 | { 755 | MenuSettings = true; 756 | } 757 | } 758 | 759 | GuiLine(LayoutRecs[4], NULL); 760 | 761 | if (MenuSettings) 762 | { 763 | ShowMenuSetiings(); 764 | } 765 | EndTextureMode(); 766 | BeginDrawing(); 767 | 768 | DrawTexturePro(Target.texture, (Rectangle){0, 0, Target.texture.width, -Target.texture.height}, (Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, (Vector2){0, 0}, 0.f, WHITE); 769 | 770 | EndDrawing(); 771 | 772 | if (IsKeyPressed(KEY_ESCAPE))exit(0); 773 | } 774 | StopMusicStream(OmegaTechData.HomeScreenMusic); 775 | OmegaTechData.Deaths = 1; 776 | } 777 | 778 | static int ScriptTimer = 0; 779 | static float X, Y, Z, S, Rotation, W, H, L; 780 | bool NextCollision = false; 781 | 782 | void CacheWDL() 783 | { 784 | wstring WData = WorldData; 785 | 786 | OtherWDLData = L""; 787 | 788 | CachedModelCounter = 0; 789 | CachedCollisionCounter = 0; 790 | 791 | bool NextCollision = false; 792 | 793 | for (int i = 0; i <= MaxCachedModels - 1; i++) 794 | { 795 | CachedModels[i].Init(); 796 | CachedCollision[i].Init(); 797 | } 798 | 799 | for (int i = 0; i <= GetWDLSize(WorldData, L""); i++) 800 | { 801 | 802 | if (CachedModelCounter == MaxCachedModels) 803 | break; 804 | 805 | wstring Instruction = WSplitValue(WData, i); 806 | 807 | if (WReadValue(Instruction, 0, 4) == L"Model" || WReadValue(Instruction, 0, 8) == L"HeightMap") 808 | { 809 | if (WReadValue(Instruction, 0, 8) != L"HeightMap") 810 | { 811 | CachedModels[CachedModelCounter].ModelId = int(ToFloat(WReadValue(Instruction, 5, 6))); 812 | } 813 | else 814 | { 815 | CachedModels[CachedModelCounter].ModelId = -1; 816 | } 817 | 818 | CachedModels[CachedModelCounter].X = ToFloat(WSplitValue(WData, i + 1)); 819 | CachedModels[CachedModelCounter].Y = ToFloat(WSplitValue(WData, i + 2)); 820 | CachedModels[CachedModelCounter].Z = ToFloat(WSplitValue(WData, i + 3)); 821 | CachedModels[CachedModelCounter].S = ToFloat(WSplitValue(WData, i + 4)); 822 | CachedModels[CachedModelCounter].R = ToFloat(WSplitValue(WData, i + 5)); 823 | 824 | if (NextCollision) 825 | { 826 | CachedModels[CachedModelCounter].Collision = true; 827 | NextCollision = false; 828 | } 829 | 830 | CachedModelCounter++; 831 | } 832 | 833 | if (WReadValue(Instruction, 0, 8) == L"Collision") 834 | { 835 | CachedModels[CachedModelCounter].ModelId = -2; 836 | CachedModels[CachedModelCounter].X = ToFloat(WSplitValue(WData, i + 1)); 837 | CachedModels[CachedModelCounter].Y = ToFloat(WSplitValue(WData, i + 2)); 838 | CachedModels[CachedModelCounter].Z = ToFloat(WSplitValue(WData, i + 3)); 839 | CachedModels[CachedModelCounter].S = ToFloat(WSplitValue(WData, i + 4)); 840 | CachedModels[CachedModelCounter].R = ToFloat(WSplitValue(WData, i + 5)); 841 | } 842 | 843 | if (WReadValue(Instruction, 0, 11) == L"AdvCollision") 844 | { 845 | CachedCollision[CachedCollisionCounter].X = ToFloat(WSplitValue(WData, i + 1)); 846 | CachedCollision[CachedCollisionCounter].Y = ToFloat(WSplitValue(WData, i + 2)); 847 | CachedCollision[CachedCollisionCounter].Z = ToFloat(WSplitValue(WData, i + 3)); 848 | CachedCollision[CachedCollisionCounter].W = ToFloat(WSplitValue(WData, i + 6)); 849 | CachedCollision[CachedCollisionCounter].H = ToFloat(WSplitValue(WData, i + 7)); 850 | CachedCollision[CachedCollisionCounter].L = ToFloat(WSplitValue(WData, i + 8)); 851 | CachedCollisionCounter ++; 852 | } 853 | 854 | if (WReadValue(Instruction, 0, 5) == L"Object" || WReadValue(Instruction, 0, 5) == L"Script") // Dont Cache Dynamic Objs 855 | { 856 | OtherWDLData += WSplitValue(WData, i) + L":" + WSplitValue(WData, i + 1) + L":" + WSplitValue(WData, i + 2) + L":" + WSplitValue(WData, i + 3) + L":" + WSplitValue(WData, i + 4) + L":" + WSplitValue(WData, i + 5) + L":"; 857 | } 858 | 859 | if (Instruction == L"C") 860 | { 861 | NextCollision = true; 862 | } 863 | } 864 | } 865 | 866 | void CWDLProcess() 867 | { 868 | for (int i = 0; i <= CachedCollisionCounter; i++) 869 | { 870 | X = CachedCollision[i].X; 871 | Y = CachedCollision[i].Y; 872 | Z = CachedCollision[i].Z; 873 | W = CachedCollision[i].W; 874 | H = CachedCollision[i].H; 875 | L = CachedCollision[i].L; 876 | 877 | if (OmegaTechData.MainCamera.position.z - OmegaTechData.RenderRadius < Z && OmegaTechData.MainCamera.position.z + OmegaTechData.RenderRadius > Z || CachedModels[i].ModelId == -1) 878 | { 879 | if (OmegaTechData.MainCamera.position.x - OmegaTechData.RenderRadius < X && OmegaTechData.MainCamera.position.x + OmegaTechData.RenderRadius > X || CachedModels[i].ModelId == -1) 880 | { 881 | if (CheckCollisionBoxSphere((BoundingBox){(Vector3){X, Y, Z}, (Vector3){W, H, L}},{OmegaTechData.MainCamera.position.x + OmegaPlayer.Width / 2,OmegaTechData.MainCamera.position.y - OmegaPlayer.Height / 2,OmegaTechData.MainCamera.position.z - OmegaPlayer.Width / 2},1.0)){ 882 | ObjectCollision = true; 883 | if (!IsSoundPlaying(OmegaTechSoundData.CollisionSound)) 884 | { 885 | PlaySound(OmegaTechSoundData.CollisionSound); 886 | } 887 | } 888 | } 889 | } 890 | } 891 | 892 | for (int i = 0; i <= CachedModelCounter; i++) 893 | { 894 | X = CachedModels[i].X; 895 | Y = CachedModels[i].Y; 896 | Z = CachedModels[i].Z; 897 | S = CachedModels[i].S; 898 | Rotation = CachedModels[i].R; 899 | 900 | if (OmegaTechData.MainCamera.position.z - OmegaTechData.RenderRadius < Z && OmegaTechData.MainCamera.position.z + OmegaTechData.RenderRadius > Z || CachedModels[i].ModelId == -1) 901 | { 902 | if (OmegaTechData.MainCamera.position.x - OmegaTechData.RenderRadius < X && OmegaTechData.MainCamera.position.x + OmegaTechData.RenderRadius > X || CachedModels[i].ModelId == -1) 903 | { 904 | 905 | switch (CachedModels[i].ModelId) 906 | { 907 | case -2: 908 | if (CheckCollisionBoxes(OmegaPlayer.PlayerBounds, (BoundingBox){(Vector3){X, Y, Z}, (Vector3){X + S, Y + S, Z + S}})) 909 | { 910 | ObjectCollision = true; 911 | if (!IsSoundPlaying(OmegaTechSoundData.CollisionSound)) 912 | { 913 | PlaySound(OmegaTechSoundData.CollisionSound); 914 | } 915 | } 916 | break; 917 | case -1: 918 | DrawModelEx(WDLModels.HeightMap, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 919 | break; 920 | case 1: 921 | DrawModelEx(WDLModels.Model1, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 922 | break; 923 | case 2: 924 | DrawModelEx(WDLModels.Model2, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 925 | break; 926 | case 3: 927 | DrawModelEx(WDLModels.Model3, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 928 | break; 929 | case 4: 930 | DrawModelEx(WDLModels.Model4, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 931 | break; 932 | case 5: 933 | DrawModelEx(WDLModels.Model5, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 934 | break; 935 | case 6: 936 | DrawModelEx(WDLModels.Model6, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 937 | break; 938 | case 7: 939 | DrawModelEx(WDLModels.Model7, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 940 | break; 941 | case 8: 942 | DrawModelEx(WDLModels.Model8, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 943 | break; 944 | case 9: 945 | DrawModelEx(WDLModels.Model9, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 946 | break; 947 | case 10: 948 | DrawModelEx(WDLModels.Model10, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 949 | break; 950 | case 11: 951 | DrawModelEx(WDLModels.Model11, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 952 | break; 953 | case 12: 954 | DrawModelEx(WDLModels.Model12, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 955 | break; 956 | case 13: 957 | DrawModelEx(WDLModels.Model13, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 958 | break; 959 | case 14: 960 | DrawModelEx(WDLModels.Model14, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 961 | break; 962 | case 15: 963 | DrawModelEx(WDLModels.Model15, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 964 | break; 965 | case 16: 966 | DrawModelEx(WDLModels.Model16, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 967 | break; 968 | case 17: 969 | DrawModelEx(WDLModels.Model17, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 970 | break; 971 | case 18: 972 | DrawModelEx(WDLModels.Model18, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 973 | break; 974 | case 19: 975 | DrawModelEx(WDLModels.Model19, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 976 | break; 977 | case 20: 978 | DrawModelEx(WDLModels.Model20, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 979 | break; 980 | default: 981 | break; 982 | } 983 | if (CachedModels[i].Collision) 984 | { 985 | BoundingBox ModelBox = {{(X - S), (Y - S), (Z - S)}, {(X + S), (Y + S), (Z + S)}}; 986 | if (CheckCollisionBoxes(OmegaPlayer.PlayerBounds, ModelBox)) 987 | { 988 | ObjectCollision = true; 989 | } 990 | } 991 | } 992 | } 993 | } 994 | } 995 | 996 | float GetDistance(float x1, float y1, float x2, float y2) { 997 | float dx = x2 - x1; 998 | float dy = y2 - y1; 999 | float distance = std::sqrt(dx * dx + dy * dy); 1000 | return distance; 1001 | } 1002 | 1003 | int FlipNumber(int num) { 1004 | int i = 100; 1005 | return i - num; 1006 | } 1007 | 1008 | 1009 | void WDLProcess() 1010 | { 1011 | 1012 | wstring WData = L""; 1013 | int Size = 0; 1014 | if (OmegaTechData.UseCachedRenderer) 1015 | { 1016 | WData = OtherWDLData + ExtraWDLInstructions; 1017 | Size = GetWDLSize(OtherWDLData, ExtraWDLInstructions); 1018 | } 1019 | else 1020 | { 1021 | WData = WorldData + ExtraWDLInstructions; 1022 | Size = GetWDLSize(WorldData, ExtraWDLInstructions); 1023 | } 1024 | 1025 | bool Render = false; 1026 | bool FoundPlatform = false; 1027 | float PlatformHeight = 0.0f; 1028 | 1029 | for (int i = 0; i <= Size; i++) 1030 | { 1031 | wstring Instruction = WSplitValue(WData, i); 1032 | 1033 | if (Instruction == L"C") 1034 | { 1035 | NextCollision = true; 1036 | } 1037 | 1038 | if (WReadValue(Instruction, 0, 4) == L"Model" || WReadValue(Instruction, 0, 1) == L"NE" || WReadValue(Instruction, 0, 6) == L"ClipBox" ||WReadValue(Instruction, 0, 5) == L"Object" || WReadValue(Instruction, 0, 5) == L"Script" || WReadValue(Instruction, 0, 8) == L"HeightMap" || WReadValue(Instruction, 0, 8) == L"Collision" || WReadValue(Instruction, 0, 11) == L"AdvCollision") 1039 | { 1040 | 1041 | X = ToFloat(WSplitValue(WData, i + 1)); 1042 | Y = ToFloat(WSplitValue(WData, i + 2)); 1043 | Z = ToFloat(WSplitValue(WData, i + 3)); 1044 | S = ToFloat(WSplitValue(WData, i + 4)); 1045 | 1046 | Rotation = ToFloat(WSplitValue(WData, i + 5)); 1047 | 1048 | if (OmegaTechData.MainCamera.position.z - OmegaTechData.RenderRadius < Z && OmegaTechData.MainCamera.position.z + OmegaTechData.RenderRadius > Z) 1049 | { 1050 | if (OmegaTechData.MainCamera.position.x - OmegaTechData.RenderRadius < X && OmegaTechData.MainCamera.position.x + OmegaTechData.RenderRadius > X) 1051 | { 1052 | Render = true; 1053 | 1054 | if (Instruction == L"NE1"){ 1055 | if (!IsMusicStreamPlaying(OmegaTechSoundData.NESound1))PlayMusicStream(OmegaTechSoundData.NESound1); 1056 | } 1057 | if (Instruction == L"NE2"){ 1058 | if (!IsMusicStreamPlaying(OmegaTechSoundData.NESound2))PlayMusicStream(OmegaTechSoundData.NESound2); 1059 | } 1060 | if (Instruction == L"NE3"){ 1061 | if (!IsMusicStreamPlaying(OmegaTechSoundData.NESound3))PlayMusicStream(OmegaTechSoundData.NESound3); 1062 | } 1063 | 1064 | } 1065 | } 1066 | } 1067 | else { 1068 | if (Instruction == L"NE1"){ 1069 | StopMusicStream(OmegaTechSoundData.NESound1); 1070 | } 1071 | if (Instruction == L"NE2"){ 1072 | StopMusicStream(OmegaTechSoundData.NESound2); 1073 | } 1074 | if (Instruction == L"NE3"){ 1075 | StopMusicStream(OmegaTechSoundData.NESound3); 1076 | } 1077 | 1078 | } 1079 | 1080 | if (Render) 1081 | { 1082 | if (WReadValue(Instruction, 0, 4) == L"Model") 1083 | { 1084 | int Identifier = ToFloat(WReadValue(Instruction, 5, 6)); 1085 | switch (Identifier) 1086 | { 1087 | case 1: 1088 | DrawModelEx(WDLModels.Model1, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1089 | break; 1090 | case 2: 1091 | DrawModelEx(WDLModels.Model2, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1092 | break; 1093 | case 3: 1094 | DrawModelEx(WDLModels.Model3, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1095 | break; 1096 | case 4: 1097 | DrawModelEx(WDLModels.Model4, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1098 | break; 1099 | case 5: 1100 | DrawModelEx(WDLModels.Model5, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1101 | break; 1102 | case 6: 1103 | DrawModelEx(WDLModels.Model6, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1104 | break; 1105 | case 7: 1106 | DrawModelEx(WDLModels.Model7, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1107 | break; 1108 | case 8: 1109 | DrawModelEx(WDLModels.Model8, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1110 | break; 1111 | case 9: 1112 | DrawModelEx(WDLModels.Model9, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1113 | break; 1114 | case 10: 1115 | DrawModelEx(WDLModels.Model10, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1116 | break; 1117 | case 11: 1118 | DrawModelEx(WDLModels.Model11, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1119 | break; 1120 | case 12: 1121 | DrawModelEx(WDLModels.Model12, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1122 | break; 1123 | case 13: 1124 | DrawModelEx(WDLModels.Model13, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1125 | break; 1126 | case 14: 1127 | DrawModelEx(WDLModels.Model14, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1128 | break; 1129 | case 15: 1130 | DrawModelEx(WDLModels.Model15, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1131 | break; 1132 | case 16: 1133 | DrawModelEx(WDLModels.Model16, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1134 | break; 1135 | case 17: 1136 | DrawModelEx(WDLModels.Model17, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1137 | break; 1138 | case 18: 1139 | DrawModelEx(WDLModels.Model18, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1140 | break; 1141 | case 19: 1142 | DrawModelEx(WDLModels.Model19, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1143 | break; 1144 | case 20: 1145 | DrawModelEx(WDLModels.Model20, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1146 | break; 1147 | default: 1148 | break; 1149 | } 1150 | } 1151 | 1152 | if (NextCollision) 1153 | { 1154 | BoundingBox ModelBox = {{(X - S), (Y - S), (Z - S)}, {(X + S), (Y + S), (Z + S)}}; 1155 | if (CheckCollisionBoxes(OmegaPlayer.PlayerBounds, ModelBox)) 1156 | { 1157 | ObjectCollision = true; 1158 | } 1159 | NextCollision = false; 1160 | } 1161 | 1162 | int AudioValue = 0; 1163 | 1164 | if (Instruction == L"NE1"){ 1165 | AudioValue = FlipNumber(GetDistance( X , Z, OmegaTechData.MainCamera.position.x , OmegaTechData.MainCamera.position.z)); 1166 | if (AudioValue > 0 && AudioValue < 100)SetMusicVolume(OmegaTechSoundData.NESound1 , float(AudioValue) / 100.0f); 1167 | else {SetMusicVolume(OmegaTechSoundData.NESound1 , 0);} 1168 | } 1169 | if (Instruction == L"NE2"){ 1170 | AudioValue = FlipNumber(GetDistance( X , Z, OmegaTechData.MainCamera.position.x , OmegaTechData.MainCamera.position.z)); 1171 | if (AudioValue > 0 && AudioValue < 100)SetMusicVolume(OmegaTechSoundData.NESound2 , float(AudioValue) / 100.0f); 1172 | else {SetMusicVolume(OmegaTechSoundData.NESound2 , 0);} 1173 | } 1174 | if (Instruction == L"NE3"){ 1175 | AudioValue = FlipNumber(GetDistance( X , Z, OmegaTechData.MainCamera.position.x , OmegaTechData.MainCamera.position.z)); 1176 | if (AudioValue > 0 && AudioValue < 100)SetMusicVolume(OmegaTechSoundData.NESound3 , float(AudioValue) / 100.0f); 1177 | else {SetMusicVolume(OmegaTechSoundData.NESound3 , 0);} 1178 | } 1179 | 1180 | 1181 | 1182 | if (Instruction == L"Object1") 1183 | DrawModelEx(OmegaTechGameObjects.Object1, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1184 | if (Instruction == L"Object2") 1185 | DrawModelEx(OmegaTechGameObjects.Object2, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1186 | if (Instruction == L"Object3") 1187 | DrawModelEx(OmegaTechGameObjects.Object3, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1188 | if (Instruction == L"Object4") 1189 | DrawModelEx(OmegaTechGameObjects.Object4, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1190 | if (Instruction == L"Object5") 1191 | DrawModelEx(OmegaTechGameObjects.Object5, {X, Y, Z}, {0, Rotation, 0}, Rotation, {S, S, S}, FadeColor); 1192 | 1193 | if (Instruction == L"Collision") 1194 | { // Collision 1195 | if (CheckCollisionBoxes(OmegaPlayer.PlayerBounds, (BoundingBox){(Vector3){X, Y, Z}, (Vector3){X + S, Y + S, Z + S}})) 1196 | { 1197 | ObjectCollision = true; 1198 | } 1199 | 1200 | if (Debug) 1201 | { 1202 | if (ObjectCollision) 1203 | { 1204 | DrawCubeWires({X, Y, Z}, S, S, S, GREEN); 1205 | } 1206 | else 1207 | { 1208 | DrawCubeWires({X, Y, Z}, S, S, S, RED); 1209 | } 1210 | } 1211 | if (ObjectCollision) 1212 | { 1213 | if (!IsSoundPlaying(OmegaTechSoundData.CollisionSound)) 1214 | { 1215 | PlaySound(OmegaTechSoundData.CollisionSound); 1216 | } 1217 | } 1218 | } 1219 | 1220 | if (WReadValue(Instruction, 0, 5) == L"Script") 1221 | { 1222 | if (CheckCollisionBoxes(OmegaPlayer.PlayerBounds, (BoundingBox){(Vector3){X, Y, Z}, (Vector3){X + S, Y + S, Z + S}})) 1223 | { 1224 | ObjectCollision = true; 1225 | if (ScriptTimer == 0) 1226 | { 1227 | ParasiteScriptInit(); 1228 | LoadScript(TextFormat("GameData/Worlds/World%i/Scripts/Script%i.ps", OmegaTechData.LevelIndex, int(ToFloat(WReadValue(Instruction, 6, Instruction.size() - 1))))); 1229 | 1230 | for (int x = 0; x <= ParasiteScriptCoreData.ProgramSize; x++) 1231 | { 1232 | CycleInstruction(); 1233 | ParasiteScriptCoreData.LineCounter++; 1234 | } 1235 | 1236 | ScriptTimer = 180; 1237 | } 1238 | } 1239 | 1240 | if (Debug) 1241 | { 1242 | if (ObjectCollision) 1243 | { 1244 | DrawCubeWires({X, Y, Z}, S, S, S, GREEN); 1245 | } 1246 | else 1247 | { 1248 | DrawCubeWires({X, Y, Z}, S, S, S, YELLOW); 1249 | } 1250 | } 1251 | } 1252 | } 1253 | if (Instruction == L"ClipBox") 1254 | { 1255 | 1256 | W = ToFloat(WSplitValue(WData, i + 6)); 1257 | H = ToFloat(WSplitValue(WData, i + 7)); 1258 | L = ToFloat(WSplitValue(WData, i + 8)); 1259 | 1260 | if (CheckCollisionBoxSphere( 1261 | (BoundingBox){(Vector3){X, Y, Z}, (Vector3){W, H, L}}, 1262 | {OmegaTechData.MainCamera.position.x + OmegaPlayer.Width / 2, 1263 | OmegaTechData.MainCamera.position.y - OmegaPlayer.Height / 2, 1264 | OmegaTechData.MainCamera.position.z - OmegaPlayer.Width / 2}, 1265 | 1.0)){ 1266 | PlatformHeight = H; 1267 | FoundPlatform = true; 1268 | } 1269 | 1270 | if (Debug)DrawBoundingBox((BoundingBox){(Vector3){X, Y, Z}, (Vector3){W, H - 5, L}}, PURPLE); 1271 | 1272 | 1273 | i += 3; 1274 | } 1275 | if (Instruction == L"AdvCollision") 1276 | { // Collision 1277 | 1278 | if (Render) 1279 | { 1280 | W = ToFloat(WSplitValue(WData, i + 6)); 1281 | H = ToFloat(WSplitValue(WData, i + 7)); 1282 | L = ToFloat(WSplitValue(WData, i + 8)); 1283 | 1284 | if (CheckCollisionBoxSphere( 1285 | (BoundingBox){(Vector3){X, Y, Z}, (Vector3){W, H, L}}, 1286 | {OmegaTechData.MainCamera.position.x + OmegaPlayer.Width / 2, 1287 | OmegaTechData.MainCamera.position.y - OmegaPlayer.Height / 2, 1288 | OmegaTechData.MainCamera.position.z - OmegaPlayer.Width / 2}, 1289 | 1.0)) 1290 | ObjectCollision = true; 1291 | 1292 | if (Debug) 1293 | { 1294 | if (ObjectCollision) 1295 | { 1296 | DrawBoundingBox((BoundingBox){(Vector3){X, Y, Z}, (Vector3){W, H, L}}, GREEN); 1297 | } 1298 | else 1299 | { 1300 | DrawBoundingBox((BoundingBox){(Vector3){X, Y, Z}, (Vector3){W, H, L}}, PURPLE); 1301 | } 1302 | } 1303 | 1304 | if (ObjectCollision) 1305 | { 1306 | if (!IsSoundPlaying(OmegaTechSoundData.CollisionSound)) 1307 | { 1308 | PlaySound(OmegaTechSoundData.CollisionSound); 1309 | } 1310 | } 1311 | } 1312 | 1313 | i += 3; 1314 | } 1315 | 1316 | if (Instruction == L"HeightMap") 1317 | { // ? 1318 | WDLModels.HeightMapPosition.x = X; 1319 | WDLModels.HeightMapPosition.y = Y; 1320 | WDLModels.HeightMapPosition.z = Z; 1321 | DrawModel(WDLModels.HeightMap, {X, Y, Z}, S, FadeColor); 1322 | } 1323 | 1324 | if (!NextCollision) 1325 | { 1326 | i += 5; 1327 | } 1328 | 1329 | Render = false; 1330 | } 1331 | 1332 | if (FoundPlatform ){ 1333 | OmegaTechData.MainCamera.position.y = PlatformHeight; 1334 | } 1335 | else { 1336 | OmegaTechData.MainCamera.position.y = 10; 1337 | } 1338 | } 1339 | 1340 | void UpdateEntities() 1341 | { 1342 | float PX = OmegaTechData.MainCamera.position.x; 1343 | float PY = OmegaTechData.MainCamera.position.y; 1344 | float PZ = OmegaTechData.MainCamera.position.z; 1345 | 1346 | float Speed = .8f; 1347 | int AttackRadius = 100; 1348 | 1349 | for (int i = 0; i <= EntityCount - 1; i++) 1350 | { 1351 | if (OmegaEnemy[i].IsActive) 1352 | { 1353 | 1354 | 1355 | DrawBillboard(OmegaTechData.MainCamera, EnemyTextures.Frame1, {OmegaEnemy[i].X, OmegaEnemy[i].Y, OmegaEnemy[i].Z}, 10.0f, WHITE); 1356 | 1357 | 1358 | if (PZ - AttackRadius < OmegaEnemy[i].Z && PZ + AttackRadius > OmegaEnemy[i].Z) 1359 | { 1360 | if (PX - AttackRadius < OmegaEnemy[i].X && PX + AttackRadius > OmegaEnemy[i].X) 1361 | { 1362 | if (OmegaEnemy[i].X > PX) 1363 | OmegaEnemy[i].X -= Speed; 1364 | if (OmegaEnemy[i].X < PX) 1365 | OmegaEnemy[i].X += Speed; 1366 | 1367 | if (OmegaEnemy[i].Z > PZ) 1368 | OmegaEnemy[i].Z -= Speed; 1369 | if (OmegaEnemy[i].Z < PZ) 1370 | OmegaEnemy[i].Z += Speed; 1371 | 1372 | if (PZ - 1 < OmegaEnemy[i].Z && PZ + 1 > OmegaEnemy[i].Z) 1373 | { 1374 | if (PX - 1 < OmegaEnemy[i].X && PX + 1 > OmegaEnemy[i].X) 1375 | { 1376 | OmegaPlayer.Health = 0; 1377 | } 1378 | } 1379 | 1380 | if (OmegaTechData.PanicCounter != 240){ 1381 | OmegaTechData.PanicCounter += 2; 1382 | } 1383 | 1384 | if (OmegaTechData.Ticker % 2 == 0) 1385 | { 1386 | if (!IsSoundPlaying(OmegaTechSoundData.ChasingSound)) 1387 | { 1388 | PlaySound(OmegaTechSoundData.ChasingSound); 1389 | } 1390 | } 1391 | } 1392 | } 1393 | } 1394 | } 1395 | } 1396 | 1397 | void UpdatePlayer() 1398 | { 1399 | if (IsKeyDown(KEY_W) || GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y) != 0 && !Debug) 1400 | { 1401 | if (HeadBob) 1402 | { 1403 | if (OmegaTechData.Ticker % 2 == 0) 1404 | { 1405 | OmegaTechData.MainCamera.target.y += OmegaPlayer.HeadBob; 1406 | if (OmegaPlayer.HeadBobDirection == 1) 1407 | { 1408 | if (OmegaPlayer.HeadBob != 1) 1409 | { 1410 | OmegaPlayer.HeadBob++; 1411 | } 1412 | else 1413 | { 1414 | OmegaPlayer.HeadBobDirection = 0; 1415 | } 1416 | } 1417 | else 1418 | { 1419 | if (OmegaPlayer.HeadBob != -1) 1420 | { 1421 | OmegaPlayer.HeadBob--; 1422 | } 1423 | else 1424 | { 1425 | OmegaPlayer.HeadBobDirection = 1; 1426 | } 1427 | } 1428 | } 1429 | } 1430 | if (!IsSoundPlaying(OmegaTechSoundData.WalkingSound)) 1431 | { 1432 | PlaySound(OmegaTechSoundData.WalkingSound); 1433 | } 1434 | } 1435 | else 1436 | { 1437 | if (IsSoundPlaying(OmegaTechSoundData.WalkingSound)) 1438 | { 1439 | StopSound(OmegaTechSoundData.WalkingSound); 1440 | } 1441 | } 1442 | 1443 | OmegaPlayer.PlayerBounds = (BoundingBox){(Vector3){OmegaTechData.MainCamera.position.x - OmegaPlayer.Width / 2, 1444 | OmegaTechData.MainCamera.position.y - OmegaPlayer.Height, 1445 | OmegaTechData.MainCamera.position.z - OmegaPlayer.Width / 2}, 1446 | (Vector3){OmegaTechData.MainCamera.position.x + OmegaPlayer.Width / 2, 1447 | OmegaTechData.MainCamera.position.y, 1448 | OmegaTechData.MainCamera.position.z + OmegaPlayer.Width / 2}}; 1449 | } 1450 | 1451 | void UpdateNoiseEmitters(){ 1452 | UpdateMusicStream(OmegaTechSoundData.NESound1); 1453 | UpdateMusicStream(OmegaTechSoundData.NESound2); 1454 | UpdateMusicStream(OmegaTechSoundData.NESound3); 1455 | } 1456 | /* 1457 | void UpdateEditor() 1458 | { 1459 | if (IsKeyDown(KEY_LEFT_SHIFT)) 1460 | { 1461 | OmegaTechEditor.DrawModel = true; 1462 | 1463 | if (IsKeyDown(KEY_ONE)) 1464 | { 1465 | 1466 | OmegaTechEditor.ModelID = 1; 1467 | } 1468 | if (IsKeyDown(KEY_TWO)) 1469 | { 1470 | 1471 | OmegaTechEditor.ModelID = 2; 1472 | } 1473 | if (IsKeyDown(KEY_THREE)) 1474 | { 1475 | 1476 | OmegaTechEditor.ModelID = 3; 1477 | } 1478 | if (IsKeyDown(KEY_FOUR)) 1479 | { 1480 | 1481 | OmegaTechEditor.ModelID = 4; 1482 | } 1483 | if (IsKeyDown(KEY_FIVE)) 1484 | { 1485 | 1486 | OmegaTechEditor.ModelID = 5; 1487 | } 1488 | if (IsKeyDown(KEY_SIX)) 1489 | { 1490 | 1491 | OmegaTechEditor.ModelID = 6; 1492 | } 1493 | if (IsKeyDown(KEY_SEVEN)) 1494 | { 1495 | 1496 | OmegaTechEditor.ModelID = 7; 1497 | } 1498 | if (IsKeyDown(KEY_EIGHT)) 1499 | { 1500 | 1501 | OmegaTechEditor.ModelID = 8; 1502 | } 1503 | if (IsKeyDown(KEY_NINE)) 1504 | { 1505 | 1506 | OmegaTechEditor.ModelID = 9; 1507 | } 1508 | if (IsKeyDown(KEY_MINUS)) 1509 | { 1510 | 1511 | OmegaTechEditor.ModelID = 10; 1512 | } 1513 | 1514 | if (IsKeyDown(KEY_Q)) 1515 | { 1516 | 1517 | OmegaTechEditor.ModelID = 11; 1518 | } 1519 | if (IsKeyDown(KEY_W)) 1520 | { 1521 | 1522 | OmegaTechEditor.ModelID = 12; 1523 | } 1524 | if (IsKeyDown(KEY_E)) 1525 | { 1526 | 1527 | OmegaTechEditor.ModelID = 13; 1528 | } 1529 | if (IsKeyDown(KEY_R)) 1530 | { 1531 | 1532 | OmegaTechEditor.ModelID = 14; 1533 | } 1534 | if (IsKeyDown(KEY_T)) 1535 | { 1536 | 1537 | OmegaTechEditor.ModelID = 15; 1538 | } 1539 | if (IsKeyDown(KEY_Y)) 1540 | { 1541 | 1542 | OmegaTechEditor.ModelID = 16; 1543 | } 1544 | if (IsKeyDown(KEY_U)) 1545 | { 1546 | 1547 | OmegaTechEditor.ModelID = 17; 1548 | } 1549 | if (IsKeyDown(KEY_I)) 1550 | { 1551 | 1552 | OmegaTechEditor.ModelID = 18; 1553 | } 1554 | if (IsKeyDown(KEY_P)) 1555 | { 1556 | 1557 | OmegaTechEditor.ModelID = 19; 1558 | } 1559 | 1560 | if (IsKeyDown(KEY_TAB)) 1561 | { 1562 | 1563 | OmegaTechEditor.ModelID = 100; 1564 | } 1565 | if (IsKeyDown(KEY_RIGHT_ALT)) 1566 | { 1567 | OmegaTechEditor.ModelID = -3; 1568 | } 1569 | if (IsKeyDown(KEY_SPACE)) 1570 | { 1571 | 1572 | OmegaTechEditor.ModelID = -1; 1573 | 1574 | OmegaTechEditor.W = OmegaTechData.MainCamera.position.x + 5; 1575 | OmegaTechEditor.H = OmegaTechData.MainCamera.position.y + 5; 1576 | OmegaTechEditor.L = OmegaTechData.MainCamera.position.z + 5; 1577 | } 1578 | if (IsKeyDown(KEY_LEFT_ALT)) 1579 | { 1580 | OmegaTechEditor.ModelID = -2; 1581 | OmegaTechEditor.W = OmegaTechData.MainCamera.position.x + 5; 1582 | OmegaTechEditor.H = OmegaTechData.MainCamera.position.y + 5; 1583 | OmegaTechEditor.L = OmegaTechData.MainCamera.position.z + 5; 1584 | } 1585 | OmegaTechEditor.X = OmegaTechData.MainCamera.position.x; 1586 | OmegaTechEditor.Y = OmegaTechData.MainCamera.position.y; 1587 | OmegaTechEditor.Z = OmegaTechData.MainCamera.position.z; 1588 | OmegaTechEditor.R = 1; 1589 | } 1590 | 1591 | if (IsKeyDown(KEY_LEFT_CONTROL)) 1592 | { 1593 | OmegaTechEditor.DrawModel = true; 1594 | 1595 | if (IsKeyDown(KEY_ONE)) 1596 | { 1597 | 1598 | OmegaTechEditor.ModelID = 101; 1599 | } 1600 | if (IsKeyDown(KEY_TWO)) 1601 | { 1602 | 1603 | OmegaTechEditor.ModelID = 102; 1604 | } 1605 | if (IsKeyDown(KEY_THREE)) 1606 | { 1607 | 1608 | OmegaTechEditor.ModelID = 103; 1609 | } 1610 | if (IsKeyDown(KEY_FOUR)) 1611 | { 1612 | 1613 | OmegaTechEditor.ModelID = 104; 1614 | } 1615 | if (IsKeyDown(KEY_FIVE)) 1616 | { 1617 | 1618 | OmegaTechEditor.ModelID = 105; 1619 | } 1620 | if (IsKeyDown(KEY_SIX)) 1621 | { 1622 | 1623 | OmegaTechEditor.ModelID = 106; 1624 | } 1625 | if (IsKeyDown(KEY_SEVEN)) 1626 | { 1627 | 1628 | OmegaTechEditor.ModelID = 107; 1629 | } 1630 | if (IsKeyDown(KEY_EIGHT)) 1631 | { 1632 | 1633 | OmegaTechEditor.ModelID = 108; 1634 | } 1635 | if (IsKeyDown(KEY_NINE)) 1636 | { 1637 | 1638 | OmegaTechEditor.ModelID = 109; 1639 | } 1640 | if (IsKeyDown(KEY_MINUS)) 1641 | { 1642 | 1643 | OmegaTechEditor.ModelID = 110; 1644 | } 1645 | OmegaTechEditor.X = OmegaTechData.MainCamera.position.x; 1646 | OmegaTechEditor.Y = OmegaTechData.MainCamera.position.y; 1647 | OmegaTechEditor.Z = OmegaTechData.MainCamera.position.z; 1648 | OmegaTechEditor.R = 1; 1649 | } 1650 | 1651 | if (OmegaTechEditor.DrawModel) 1652 | { 1653 | switch (OmegaTechEditor.ModelID) 1654 | { 1655 | case 1: 1656 | DrawModelEx(WDLModels.Model1, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1657 | break; 1658 | case 2: 1659 | DrawModelEx(WDLModels.Model2, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1660 | break; 1661 | case 3: 1662 | DrawModelEx(WDLModels.Model3, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1663 | break; 1664 | case 4: 1665 | DrawModelEx(WDLModels.Model4, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1666 | break; 1667 | case 5: 1668 | DrawModelEx(WDLModels.Model5, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1669 | break; 1670 | case 6: 1671 | DrawModelEx(WDLModels.Model6, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1672 | break; 1673 | case 7: 1674 | DrawModelEx(WDLModels.Model7, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1675 | break; 1676 | case 8: 1677 | DrawModelEx(WDLModels.Model8, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1678 | break; 1679 | case 9: 1680 | DrawModelEx(WDLModels.Model9, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1681 | break; 1682 | case 10: 1683 | DrawModelEx(WDLModels.Model10, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1684 | break; 1685 | case 11: 1686 | DrawModelEx(WDLModels.Model11, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1687 | break; 1688 | case 12: 1689 | DrawModelEx(WDLModels.Model12, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1690 | break; 1691 | case 13: 1692 | DrawModelEx(WDLModels.Model13, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1693 | break; 1694 | case 14: 1695 | DrawModelEx(WDLModels.Model14, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1696 | break; 1697 | case 15: 1698 | DrawModelEx(WDLModels.Model15, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1699 | break; 1700 | case 16: 1701 | DrawModelEx(WDLModels.Model16, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1702 | break; 1703 | case 17: 1704 | DrawModelEx(WDLModels.Model17, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1705 | break; 1706 | case 18: 1707 | DrawModelEx(WDLModels.Model18, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1708 | break; 1709 | case 19: 1710 | DrawModelEx(WDLModels.Model19, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1711 | break; 1712 | case 20: 1713 | DrawModelEx(WDLModels.Model20, {OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, {0, OmegaTechEditor.R, 0}, OmegaTechEditor.R, {OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S}, FadeColor); 1714 | break; 1715 | case -1: 1716 | DrawBoundingBox((BoundingBox){(Vector3){OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, (Vector3){OmegaTechEditor.W, OmegaTechEditor.H, OmegaTechEditor.L}}, ORANGE); 1717 | DrawCubeWires({OmegaTechEditor.W, OmegaTechEditor.H, OmegaTechEditor.L}, OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S, PINK); 1718 | break; 1719 | case -2: 1720 | DrawBoundingBox((BoundingBox){(Vector3){OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, (Vector3){OmegaTechEditor.W, OmegaTechEditor.H - 5, OmegaTechEditor.L}}, ORANGE); 1721 | DrawCubeWires({OmegaTechEditor.W, OmegaTechEditor.H - 5, OmegaTechEditor.L}, OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S, PINK); 1722 | break; 1723 | } 1724 | 1725 | if (OmegaTechEditor.ModelID <= 100 || OmegaTechEditor.ModelID == -3) 1726 | DrawCubeWires({OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S, PINK); 1727 | else 1728 | { 1729 | DrawCubeWires({OmegaTechEditor.X, OmegaTechEditor.Y, OmegaTechEditor.Z}, OmegaTechEditor.S, OmegaTechEditor.S, OmegaTechEditor.S, ORANGE); 1730 | } 1731 | 1732 | if (!IsMouseButtonDown(2)) 1733 | { 1734 | if (IsKeyPressed(KEY_U)) 1735 | { 1736 | OmegaTechEditor.X -= 5.0f; 1737 | } 1738 | if (IsKeyPressed(KEY_J)) 1739 | { 1740 | OmegaTechEditor.X += 5.0f; 1741 | } 1742 | if (IsKeyPressed(KEY_H)) 1743 | { 1744 | OmegaTechEditor.Z += 5.0f; 1745 | } 1746 | if (IsKeyPressed(KEY_K)) 1747 | { 1748 | OmegaTechEditor.Z -= 5.0f; 1749 | } 1750 | if (IsKeyPressed(KEY_Y)) 1751 | { 1752 | OmegaTechEditor.Y -= 5.0f; 1753 | } 1754 | if (IsKeyPressed(KEY_I)) 1755 | { 1756 | OmegaTechEditor.Y += 5.0f; 1757 | } 1758 | } 1759 | else 1760 | { 1761 | if (IsKeyPressed(KEY_U)) 1762 | { 1763 | OmegaTechEditor.W -= 5.0f; 1764 | } 1765 | if (IsKeyPressed(KEY_J)) 1766 | { 1767 | OmegaTechEditor.W += 5.0f; 1768 | } 1769 | if (IsKeyPressed(KEY_H)) 1770 | { 1771 | OmegaTechEditor.L += 5.0f; 1772 | } 1773 | if (IsKeyPressed(KEY_K)) 1774 | { 1775 | OmegaTechEditor.L -= 5.0f; 1776 | } 1777 | if (IsKeyPressed(KEY_Y)) 1778 | { 1779 | OmegaTechEditor.H -= 5.0f; 1780 | } 1781 | if (IsKeyPressed(KEY_I)) 1782 | { 1783 | OmegaTechEditor.H += 5.0f; 1784 | } 1785 | } 1786 | 1787 | if (IsKeyPressed(KEY_O)) 1788 | { 1789 | OmegaTechEditor.R += 90.0f; 1790 | } 1791 | if (IsKeyPressed(KEY_L)) 1792 | { 1793 | OmegaTechEditor.R -= 90.0f; 1794 | } 1795 | if (IsKeyDown(KEY_T)) 1796 | { 1797 | OmegaTechEditor.S += .5f; 1798 | } 1799 | if (IsKeyDown(KEY_G)) 1800 | { 1801 | OmegaTechEditor.S -= .5f; 1802 | } 1803 | 1804 | if (IsKeyPressed(KEY_ENTER) || IsMouseButtonPressed(1)) 1805 | { 1806 | wstring WDLCommand = L""; 1807 | 1808 | wstring Id = L""; 1809 | 1810 | if (OmegaTechEditor.ModelID > 0) 1811 | { 1812 | if (OmegaTechEditor.ModelID != 100) 1813 | { 1814 | if (OmegaTechEditor.ModelID < 100) 1815 | { 1816 | Id = L"Model"; 1817 | WDLCommand += Id + to_wstring(OmegaTechEditor.ModelID) + L":"; 1818 | } 1819 | else 1820 | { 1821 | Id = L"Script"; 1822 | WDLCommand += Id + to_wstring(OmegaTechEditor.ModelID - 100) + L":"; 1823 | } 1824 | } 1825 | else 1826 | { 1827 | Id = L"Collision"; 1828 | WDLCommand += Id + L":"; 1829 | } 1830 | 1831 | WDLCommand += to_wstring(OmegaTechEditor.X) + L":" + to_wstring(OmegaTechEditor.Y) + L":" + to_wstring(OmegaTechEditor.Z) + L":" + to_wstring(OmegaTechEditor.S) + L":" + to_wstring(OmegaTechEditor.R) + L":"; 1832 | } 1833 | else { 1834 | if (OmegaTechEditor.ModelID == -1) 1835 | { 1836 | WDLCommand += L"AdvCollision:"; 1837 | WDLCommand += to_wstring(OmegaTechEditor.X) + L":" + to_wstring(OmegaTechEditor.Y) + L":" + to_wstring(OmegaTechEditor.Z) + L":" + to_wstring(OmegaTechEditor.S) + L":" + to_wstring(OmegaTechEditor.R) + L":" + to_wstring(OmegaTechEditor.W) + L":" + to_wstring(OmegaTechEditor.H) + L":" + to_wstring(OmegaTechEditor.L) + L":"; 1838 | } 1839 | 1840 | if (OmegaTechEditor.ModelID == -2) 1841 | { 1842 | WDLCommand += L"ClipBox:"; 1843 | WDLCommand += to_wstring(OmegaTechEditor.X) + L":" + to_wstring(OmegaTechEditor.Y) + L":" + to_wstring(OmegaTechEditor.Z) + L":" + to_wstring(OmegaTechEditor.S) + L":" + to_wstring(OmegaTechEditor.R) + L":" + to_wstring(OmegaTechEditor.W) + L":" + to_wstring(OmegaTechEditor.H) + L":" + to_wstring(OmegaTechEditor.L) + L":"; 1844 | } 1845 | 1846 | if (OmegaTechEditor.ModelID == -3){ 1847 | WDLCommand += L"NE1:" + to_wstring(OmegaTechEditor.X) + L":" + to_wstring(OmegaTechEditor.Y) + L":" + to_wstring(OmegaTechEditor.Z) + L":" + to_wstring(OmegaTechEditor.S) + L":" + to_wstring(OmegaTechEditor.R) + L":"; 1848 | } 1849 | } 1850 | 1851 | wcout << WDLCommand << "\n"; 1852 | 1853 | WorldData += WDLCommand; 1854 | 1855 | OmegaTechEditor.DrawModel = false; 1856 | } 1857 | 1858 | if (OmegaInputController.InteractDown) 1859 | { 1860 | OmegaTechEditor.X += GetMouseDelta().x / 8; 1861 | OmegaTechEditor.Y += GetMouseDelta().y / 8; 1862 | OmegaTechEditor.Z -= (GetMouseWheelMove() * 2); 1863 | } 1864 | } 1865 | if (IsKeyPressed(KEY_RIGHT_SHIFT)) 1866 | { 1867 | wofstream Outfile; 1868 | Outfile.open(TextFormat("GameData/Worlds/World%i/World.wdl", OmegaTechData.LevelIndex)); 1869 | 1870 | if (GameDataEncoded) 1871 | { 1872 | Outfile << Encode(WorldData, MainKey) << "\n"; 1873 | } 1874 | else 1875 | { 1876 | Outfile << WorldData << "\n"; 1877 | } 1878 | } 1879 | } 1880 | */ 1881 | 1882 | void SaveGame() 1883 | { 1884 | wstring TFlags = L""; 1885 | 1886 | for (int i = 0; i <= 99; i++) 1887 | { 1888 | if (ToggleFlags[i].Value == 1) 1889 | { 1890 | TFlags += L'1'; 1891 | } 1892 | if (ToggleFlags[i].Value == 0) 1893 | { 1894 | TFlags += L'0'; 1895 | } 1896 | } 1897 | 1898 | TFlags += L':'; 1899 | 1900 | if (OmegaTechGameObjects.Object1Owned)TFlags += L'1'; 1901 | else {TFlags += L'0';} 1902 | if (OmegaTechGameObjects.Object2Owned)TFlags += L'1'; 1903 | else {TFlags += L'0';} 1904 | if (OmegaTechGameObjects.Object3Owned)TFlags += L'1'; 1905 | else {TFlags += L'0';} 1906 | if (OmegaTechGameObjects.Object4Owned)TFlags += L'1'; 1907 | else {TFlags += L'0';} 1908 | if (OmegaTechGameObjects.Object5Owned)TFlags += L'1'; 1909 | else {TFlags += L'0';} 1910 | 1911 | wofstream Outfile; 1912 | Outfile.open("GameData/Saves/TF.sav"); 1913 | Outfile << TFlags; 1914 | 1915 | wstring Position = to_wstring(OmegaTechData.MainCamera.position.x) + L':' + 1916 | to_wstring(OmegaTechData.MainCamera.position.y) + L':' + 1917 | to_wstring(OmegaTechData.MainCamera.position.z) + L':' + 1918 | to_wstring(OmegaTechData.LevelIndex) + L':'; 1919 | 1920 | wofstream Outfile1; 1921 | Outfile1.open("GameData/Saves/POS.sav"); 1922 | Outfile1 << Position; 1923 | 1924 | wofstream Outfile2; 1925 | Outfile2.open("GameData/Saves/Script.sav"); 1926 | Outfile2 << ExtraWDLInstructions; 1927 | } 1928 | 1929 | void LoadSave() 1930 | { 1931 | wstring TFlags = LoadFile("GameData/Saves/TF.sav"); 1932 | 1933 | for (int i = 0; i <= 99; i++) 1934 | { 1935 | if (TFlags[i] == L'1') 1936 | { 1937 | ToggleFlags[i].Value = 1; 1938 | } 1939 | if (TFlags[i] == L'0') 1940 | { 1941 | ToggleFlags[i].Value = 0; 1942 | } 1943 | } 1944 | 1945 | if (TFlags[101] == L'1')OmegaTechGameObjects.Object1Owned = true; 1946 | if (TFlags[102] == L'1')OmegaTechGameObjects.Object2Owned = true; 1947 | if (TFlags[103] == L'1')OmegaTechGameObjects.Object3Owned = true; 1948 | if (TFlags[104] == L'1')OmegaTechGameObjects.Object4Owned = true; 1949 | if (TFlags[105] == L'1')OmegaTechGameObjects.Object5Owned = true; 1950 | 1951 | wstring Position = LoadFile("GameData/Saves/POS.sav"); 1952 | 1953 | OmegaTechData.LevelIndex = int(ToFloat(WSplitValue(Position, 3))); 1954 | 1955 | SetCameraFlag = true; 1956 | 1957 | int X = ToFloat(WSplitValue(Position, 0)); 1958 | int Y = ToFloat(WSplitValue(Position, 1)); 1959 | int Z = ToFloat(WSplitValue(Position, 2)); 1960 | SetCameraPos = {float(X), float(Y), float(Z)}; 1961 | 1962 | ExtraWDLInstructions = LoadFile("GameData/Saves/Script.sav"); 1963 | } 1964 | 1965 | void DrawWorld() 1966 | { 1967 | BeginTextureMode(Target); 1968 | ClearBackground(BLACK); 1969 | if (OmegaTechData.SkyboxEnabled) 1970 | { 1971 | DrawTexture(WDLModels.Skybox, 0, 0, FadeColor); 1972 | } 1973 | BeginMode3D(OmegaTechData.MainCamera); 1974 | 1975 | BeginShaderMode(OmegaTechData.ToonShader); 1976 | 1977 | 1978 | if (OmegaTechSoundData.MusicFound) 1979 | { 1980 | UpdateMusicStream(OmegaTechSoundData.BackgroundMusic); 1981 | } 1982 | 1983 | UpdateNoiseEmitters(); 1984 | 1985 | if (!OmegaTechData.UseCachedRenderer) 1986 | { 1987 | WDLProcess(); 1988 | } 1989 | else 1990 | { 1991 | CWDLProcess(); 1992 | WDLProcess(); 1993 | } 1994 | 1995 | 1996 | 1997 | UpdatePlayer(); 1998 | 1999 | 2000 | 2001 | if (Debug) 2002 | { 2003 | DrawLights(); 2004 | } 2005 | else 2006 | { 2007 | UpdateEntities(); 2008 | } 2009 | if (ObjectCollision) 2010 | { 2011 | OmegaTechData.MainCamera.position.x = OmegaPlayer.OldX; 2012 | OmegaTechData.MainCamera.position.y = OmegaPlayer.OldY; 2013 | OmegaTechData.MainCamera.position.z = OmegaPlayer.OldZ; 2014 | ObjectCollision = false; 2015 | } 2016 | 2017 | UpdateCustom(); 2018 | 2019 | EndShaderMode(); 2020 | 2021 | EndMode3D(); 2022 | EndTextureMode(); 2023 | 2024 | if (SetSceneFlag) 2025 | { 2026 | OmegaTechData.LevelIndex = SetSceneId; 2027 | LoadWorld(); 2028 | SetSceneFlag = false; 2029 | } 2030 | 2031 | if (SetCameraFlag) 2032 | { 2033 | OmegaTechData.MainCamera.position = SetCameraPos; 2034 | SetCameraFlag = false; 2035 | } 2036 | 2037 | if (ScriptTimer != 0) 2038 | { 2039 | ScriptTimer--; 2040 | } 2041 | 2042 | if (OmegaTechData.Ticker != 60) 2043 | { 2044 | OmegaTechData.Ticker++; 2045 | } 2046 | else 2047 | { 2048 | OmegaTechData.Ticker = 0; 2049 | } 2050 | } 2051 | 2052 | 2053 | 2054 | -------------------------------------------------------------------------------- /Source/Custom/OTCustom.cpp: -------------------------------------------------------------------------------- 1 | #include "OTCustom.hpp" 2 | #include 3 | 4 | void UpdateCustom(){ 5 | 6 | } 7 | 8 | -------------------------------------------------------------------------------- /Source/Custom/OTCustom.hpp: -------------------------------------------------------------------------------- 1 | #ifndef OTCUSTOM_H 2 | #define OTCUSTOM_H 3 | 4 | void UpdateCustom(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /Source/Data.hpp: -------------------------------------------------------------------------------- 1 | #include "raylib.h" 2 | #include "Settings.hpp" 3 | #include "Player.hpp" 4 | #include "Editor.hpp" 5 | #include "Video.hpp" 6 | #include "ParticleDemon/ParticleDemon.hpp" 7 | #include "Parasite/ParasiteScript.hpp" 8 | #include "Encoder/Encoder.hpp" 9 | #include "Entities.hpp" 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace std; 18 | 19 | #define MaxCachedModels 200 20 | 21 | 22 | static wstring WorldData; 23 | static wstring OtherWDLData; 24 | 25 | 26 | static int R = 0; 27 | static int G = 0; 28 | static int B = 0; 29 | 30 | int Direction = 1; 31 | bool FadeDone = false; 32 | Color FadeColor = (Color){R, G, B, 255}; 33 | 34 | void PlayFade() 35 | { 36 | Direction = 1; 37 | R = 0; 38 | G = 0; 39 | B = 0; 40 | FadeDone = false; 41 | } 42 | 43 | 44 | 45 | class GameModels 46 | { 47 | public: 48 | Texture2D Skybox; 49 | 50 | Vector3 HeightMapPosition; 51 | 52 | // OBJ Models 53 | 54 | Model HeightMap; 55 | Texture2D HeightMapTexture; 56 | 57 | Model Model1; 58 | Texture2D Model1Texture; 59 | 60 | Model Model2; 61 | Texture2D Model2Texture; 62 | 63 | Model Model3; 64 | Texture2D Model3Texture; 65 | 66 | Model Model4; 67 | Texture2D Model4Texture; 68 | 69 | Model Model5; 70 | Texture2D Model5Texture; 71 | 72 | Model Model6; 73 | Texture2D Model6Texture; 74 | 75 | Model Model7; 76 | Texture2D Model7Texture; 77 | 78 | Model Model8; 79 | Texture2D Model8Texture; 80 | 81 | Model Model9; 82 | Texture2D Model9Texture; 83 | 84 | Model Model10; 85 | Texture2D Model10Texture; 86 | 87 | Model Model11; 88 | Texture2D Model11Texture; 89 | 90 | Model Model12; 91 | Texture2D Model12Texture; 92 | 93 | Model Model13; 94 | Texture2D Model13Texture; 95 | 96 | Model Model14; 97 | Texture2D Model14Texture; 98 | 99 | Model Model15; 100 | Texture2D Model15Texture; 101 | 102 | Model Model16; 103 | Texture2D Model16Texture; 104 | 105 | Model Model17; 106 | Texture2D Model17Texture; 107 | 108 | Model Model18; 109 | Texture2D Model18Texture; 110 | 111 | Model Model19; 112 | Texture2D Model19Texture; 113 | 114 | Model Model20; 115 | Texture2D Model20Texture; 116 | 117 | // GLTS Models 118 | 119 | // For Faster Rendering. 120 | 121 | Model FastModel1; 122 | Texture2D FastModel1Texture; 123 | Model FastModel2; 124 | Texture2D FastModel2Texture; 125 | Model FastModel3; 126 | Texture2D FastModel3Texture; 127 | Model FastModel4; 128 | Texture2D FastModel4Texture; 129 | Model FastModel5; 130 | Texture2D FastModel5Texture; 131 | }; 132 | 133 | static GameModels WDLModels; 134 | 135 | class GameData{ 136 | public: 137 | float X; 138 | float Y; 139 | float Z; 140 | float R; 141 | float S; 142 | int ModelId; 143 | bool Collision; 144 | 145 | void Init(){ 146 | X = 0; 147 | Y = 0; 148 | Z = 0; 149 | R = 0; 150 | S = 0; 151 | ModelId = 0; 152 | Collision = false; 153 | } 154 | 155 | }; 156 | 157 | static int CachedModelCounter = 0; 158 | static GameData CachedModels[MaxCachedModels]; 159 | 160 | class CollisionData{ 161 | public: 162 | float X; 163 | float Y; 164 | float Z; 165 | float W; 166 | float H; 167 | float L; 168 | 169 | void Init(){ 170 | X = 0; 171 | Y = 0; 172 | Z = 0; 173 | W = 0; 174 | H = 0; 175 | L = 0; 176 | } 177 | 178 | }; 179 | 180 | static int CachedCollisionCounter = 0; 181 | static CollisionData CachedCollision[MaxCachedModels]; 182 | 183 | class GameSounds 184 | { 185 | public: 186 | Sound CollisionSound; 187 | Sound WalkingSound; 188 | Music BackgroundMusic; 189 | Sound UIClick; 190 | Sound ChasingSound; 191 | Sound Death; 192 | 193 | Music NESound1; 194 | Music NESound2; 195 | Music NESound3; 196 | 197 | bool MusicFound = false; 198 | }; 199 | 200 | static GameSounds OmegaTechSoundData; 201 | -------------------------------------------------------------------------------- /Source/Editor.hpp: -------------------------------------------------------------------------------- 1 | class Editor{ 2 | public: 3 | bool DrawModel = false; 4 | int ModelID = 1; 5 | float X = 0; 6 | float Y = 0; 7 | float Z = 0; 8 | float S = 1; 9 | float R = 0; 10 | 11 | float L = 0; 12 | float H = 0; 13 | float W = 0; 14 | 15 | }; 16 | 17 | static Editor OmegaTechEditor; -------------------------------------------------------------------------------- /Source/Encoder/Encoder.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | 6 | using namespace std; 7 | 8 | // ghidefjklmnovwstuxyzabcpqr0123456789 9 | 10 | wstring Encode(wstring Data, wstring Key){ 11 | wstring Out = L""; 12 | 13 | for (int i=0; i <= Data.size(); i ++){ 14 | switch (Data[i]){ 15 | case L'A': 16 | Out += Key[0]; 17 | break; 18 | case L'B': 19 | Out += Key[1]; 20 | break; 21 | case L'C': 22 | Out += Key[2]; 23 | break; 24 | case L'D': 25 | Out += Key[3]; 26 | break; 27 | case L'E': 28 | Out += Key[4]; 29 | break; 30 | case L'F': 31 | Out += Key[5]; 32 | break; 33 | case L'G': 34 | Out += Key[6]; 35 | break; 36 | case L'H': 37 | Out += Key[7]; 38 | break; 39 | case L'I': 40 | Out += Key[8]; 41 | break; 42 | case L'J': 43 | Out += Key[9]; 44 | break; 45 | case L'K': 46 | Out += Key[10]; 47 | break; 48 | case L'L': 49 | Out += Key[11]; 50 | break; 51 | case L'M': 52 | Out += Key[12]; 53 | break; 54 | case L'N': 55 | Out += Key[13]; 56 | break; 57 | case L'O': 58 | Out += Key[14]; 59 | break; 60 | case L'P': 61 | Out += Key[15]; 62 | break; 63 | case L'Q': 64 | Out += Key[16]; 65 | break; 66 | case L'R': 67 | Out += Key[17]; 68 | break; 69 | case L'S': 70 | Out += Key[18]; 71 | break; 72 | case L'T': 73 | Out += Key[19]; 74 | break; 75 | case L'U': 76 | Out += Key[20]; 77 | break; 78 | case L'V': 79 | Out += Key[21]; 80 | break; 81 | case L'W': 82 | Out += Key[22]; 83 | break; 84 | case L'X': 85 | Out += Key[23]; 86 | break; 87 | case L'Y': 88 | Out += Key[24]; 89 | break; 90 | case L'Z': 91 | Out += Key[25]; 92 | break; 93 | case L'a': 94 | Out += Key[0 + 26]; 95 | break; 96 | case L'b': 97 | Out += Key[1 + 26]; 98 | break; 99 | case L'c': 100 | Out += Key[2 + 26]; 101 | break; 102 | case L'd': 103 | Out += Key[3 + 26]; 104 | break; 105 | case L'e': 106 | Out += Key[4 + 26]; 107 | break; 108 | case L'f': 109 | Out += Key[5 + 26]; 110 | break; 111 | case L'g': 112 | Out += Key[6 + 26]; 113 | break; 114 | case L'h': 115 | Out += Key[7 + 26]; 116 | break; 117 | case L'i': 118 | Out += Key[8 + 26]; 119 | break; 120 | case L'j': 121 | Out += Key[9 + 26]; 122 | break; 123 | case L'k': 124 | Out += Key[10 + 26]; 125 | break; 126 | case L'l': 127 | Out += Key[11 + 26]; 128 | break; 129 | case L'm': 130 | Out += Key[12 + 26]; 131 | break; 132 | case L'n': 133 | Out += Key[13 + 26]; 134 | break; 135 | case L'o': 136 | Out += Key[14 + 26]; 137 | break; 138 | case L'p': 139 | Out += Key[15 + 26]; 140 | break; 141 | case L'q': 142 | Out += Key[16 + 26]; 143 | break; 144 | case L'r': 145 | Out += Key[17 + 26]; 146 | break; 147 | case L's': 148 | Out += Key[18 + 26]; 149 | break; 150 | case L't': 151 | Out += Key[19 + 26]; 152 | break; 153 | case L'u': 154 | Out += Key[20 + 26]; 155 | break; 156 | case L'v': 157 | Out += Key[21 + 26]; 158 | break; 159 | case L'w': 160 | Out += Key[22 + 26]; 161 | break; 162 | case L'x': 163 | Out += Key[23 + 26]; 164 | break; 165 | case L'y': 166 | Out += Key[24 + 26]; 167 | break; 168 | case L'z': 169 | Out += Key[25 + 26]; 170 | break; 171 | 172 | case L'0': 173 | Out += Key[52]; 174 | break; 175 | case L'1': 176 | Out += Key[53]; 177 | break; 178 | case L'2': 179 | Out += Key[54]; 180 | break; 181 | case L'3': 182 | Out += Key[55]; 183 | break; 184 | case L'4': 185 | Out += Key[56]; 186 | break; 187 | case L'5': 188 | Out += Key[57]; 189 | break; 190 | case L'6': 191 | Out += Key[58]; 192 | break; 193 | case L'7': 194 | Out += Key[59]; 195 | break; 196 | case L'8': 197 | Out += Key[60]; 198 | break; 199 | case L'9': 200 | Out += Key[61]; 201 | break; 202 | 203 | default: 204 | Out += Data[i]; 205 | break; 206 | } 207 | } 208 | return Out; 209 | } 210 | -------------------------------------------------------------------------------- /Source/Encoder/Encoder.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | static bool GameDataEncoded = false; 7 | 8 | wstring MainKey = L"9876543210zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA"; 9 | 10 | wstring Encode(wstring Data, wstring Key); 11 | -------------------------------------------------------------------------------- /Source/Entities.hpp: -------------------------------------------------------------------------------- 1 | #include "raylib.h" 2 | 3 | #define EntityCount 10 4 | 5 | class Enemys{ 6 | public: 7 | bool IsActive = false; 8 | bool Scream = false; 9 | 10 | float Height = 10.0f; 11 | float Width = 2.0f; 12 | 13 | float X = 0.0f; 14 | float Y = 0.0f; 15 | float Z = 0.0f; 16 | 17 | float OldX = 0.0f; 18 | float OldY = 0.0f; 19 | float OldZ = 0.0f; 20 | 21 | }; 22 | 23 | static Enemys OmegaEnemy[10]; 24 | 25 | 26 | class EnemyTexture{ 27 | public: 28 | Texture2D Frame1; 29 | Sound Scream; 30 | }; 31 | 32 | static EnemyTexture EnemyTextures; -------------------------------------------------------------------------------- /Source/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "Core.hpp" 2 | 3 | 4 | int main(){ 5 | SetConfigFlags(FLAG_VSYNC_HINT); 6 | 7 | InitWindow(1280 , 720 , "Project Omega"); 8 | SetTargetFPS(60); 9 | 10 | InitAudioDevice(); 11 | 12 | if (!IsAudioDeviceReady()){ 13 | CloseAudioDevice(); 14 | } 15 | 16 | OmegaTechInit(); 17 | PlayHomeScreen(); 18 | 19 | LoadWorld(); 20 | 21 | HideCursor(); 22 | DisableCursor(); 23 | 24 | while (!WindowShouldClose()) 25 | { 26 | OmegaPlayer.OldX = OmegaTechData.MainCamera.position.x; 27 | OmegaPlayer.OldY = OmegaTechData.MainCamera.position.y; 28 | OmegaPlayer.OldZ = OmegaTechData.MainCamera.position.z; 29 | 30 | if (!OmegaInputController.InteractDown && !ShowSettings){ 31 | for (int i = 0 ; i <= OmegaTechData.CameraSpeed; i ++){ 32 | UpdateCamera(&OmegaTechData.MainCamera, CAMERA_FIRST_PERSON); 33 | } 34 | } 35 | 36 | OmegaInputController.UpdateInputs(); 37 | UpdateLightSources(); 38 | 39 | if (Direction == 1) 40 | { 41 | R += 1; 42 | G += 1; 43 | B += 1; 44 | 45 | if (R == 254) 46 | { 47 | FadeDone = true; 48 | Direction = 3; 49 | } 50 | } 51 | 52 | FadeColor = (Color){R, G, B, 255}; 53 | 54 | 55 | DrawWorld(); 56 | 57 | 58 | BeginDrawing(); 59 | 60 | ClearBackground(BLACK); 61 | 62 | DrawTexturePro(Target.texture, (Rectangle){ 0, 0, Target.texture.width, -Target.texture.height }, (Rectangle){ 0, 0, float(GetScreenWidth()), float(GetScreenHeight())}, (Vector2){ 0, 0 } , 0.f , WHITE); 63 | UpdateObjectBar(); 64 | EndShaderMode(); 65 | 66 | if (ParticlesEnabled){ 67 | OmegaTechData.RainParticles.Update(0,0); 68 | OmegaTechData.RainParticles.TriggerEffect({0,0} , RainEffect); 69 | } 70 | 71 | if (FPSEnabled){ 72 | DrawFPS(0,0); 73 | } 74 | 75 | UpdateSettings(); 76 | 77 | 78 | OmegaTechTextSystem.Update(); 79 | 80 | 81 | EndDrawing(); 82 | 83 | if (IsKeyPressed(KEY_F11))ToggleFullscreen(); 84 | 85 | } 86 | 87 | CloseWindow(); 88 | } -------------------------------------------------------------------------------- /Source/Objects.hpp: -------------------------------------------------------------------------------- 1 | #include "PPGIO.hpp" 2 | 3 | class GameObject 4 | { 5 | public: 6 | Font BarFont; 7 | Texture2D ObjectBar; 8 | 9 | Model Object1; 10 | wstring Object1Name; 11 | Texture2D Object1Texture; 12 | Texture2D Object1Icon; 13 | bool Object1Owned; 14 | 15 | Model Object2; 16 | wstring Object2Name; 17 | Texture2D Object2Texture; 18 | Texture2D Object2Icon; 19 | bool Object2Owned; 20 | 21 | Model Object3; 22 | wstring Object3Name; 23 | Texture2D Object3Texture; 24 | Texture2D Object3Icon; 25 | bool Object3Owned; 26 | 27 | Model Object4; 28 | wstring Object4Name; 29 | Texture2D Object4Texture; 30 | Texture2D Object4Icon; 31 | bool Object4Owned; 32 | 33 | Model Object5; 34 | wstring Object5Name; 35 | Texture2D Object5Texture; 36 | Texture2D Object5Icon; 37 | bool Object5Owned; 38 | 39 | }; 40 | 41 | static GameObject OmegaTechGameObjects; 42 | 43 | void InitObjects(){ 44 | OmegaTechGameObjects.ObjectBar = LoadTexture("GameData/Global/ObjectBar.png"); 45 | OmegaTechGameObjects.BarFont = LoadFont("GameData/Global/Font.ttf"); 46 | 47 | 48 | if (IsPathFile("GameData/Global/Objects/Object1.obj")){ 49 | OmegaTechGameObjects.Object1 = LoadModel("GameData/Global/Objects/Object1.obj"); 50 | OmegaTechGameObjects.Object1Texture = LoadTexture("GameData/Global/Objects/Object1Texture.png"); 51 | OmegaTechGameObjects.Object1Icon = LoadTexture("GameData/Global/Objects/Object1Icon.png"); 52 | OmegaTechGameObjects.Object1.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = OmegaTechGameObjects.Object1Texture; 53 | OmegaTechGameObjects.Object1Owned = false; 54 | OmegaTechGameObjects.Object1Name = WSplitValue(LoadFile("GameData/Global/Objects/Object1.info") , 0); 55 | } 56 | 57 | if (IsPathFile("GameData/Global/Objects/Object2.obj")){ 58 | OmegaTechGameObjects.Object2 = LoadModel("GameData/Global/Objects/Object2.obj"); 59 | OmegaTechGameObjects.Object2Texture = LoadTexture("GameData/Global/Objects/Object2Texture.png"); 60 | OmegaTechGameObjects.Object2Icon = LoadTexture("GameData/Global/Objects/Object2Icon.png"); 61 | OmegaTechGameObjects.Object2.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = OmegaTechGameObjects.Object2Texture; 62 | OmegaTechGameObjects.Object2Owned = false; 63 | OmegaTechGameObjects.Object2Name = WSplitValue(LoadFile("GameData/Global/Objects/Object2.info") , 0); 64 | } 65 | 66 | if (IsPathFile("GameData/Global/Objects/Object3.obj")){ 67 | OmegaTechGameObjects.Object3 = LoadModel("GameData/Global/Objects/Object3.obj"); 68 | OmegaTechGameObjects.Object3Texture = LoadTexture("GameData/Global/Objects/Object3Texture.png"); 69 | OmegaTechGameObjects.Object3Icon = LoadTexture("GameData/Global/Objects/Object3Icon.png"); 70 | OmegaTechGameObjects.Object3.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = OmegaTechGameObjects.Object3Texture; 71 | OmegaTechGameObjects.Object3Owned = false; 72 | OmegaTechGameObjects.Object3Name = WSplitValue(LoadFile("GameData/Global/Objects/Object3.info") , 0); 73 | } 74 | 75 | if (IsPathFile("GameData/Global/Objects/Object4.obj")){ 76 | OmegaTechGameObjects.Object4 = LoadModel("GameData/Global/Objects/Object4.obj"); 77 | OmegaTechGameObjects.Object4Texture = LoadTexture("GameData/Global/Objects/Object4Texture.png"); 78 | OmegaTechGameObjects.Object4Icon = LoadTexture("GameData/Global/Objects/Object4Icon.png"); 79 | OmegaTechGameObjects.Object4.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = OmegaTechGameObjects.Object4Texture; 80 | OmegaTechGameObjects.Object4Owned = false; 81 | OmegaTechGameObjects.Object4Name = WSplitValue(LoadFile("GameData/Global/Objects/Object4.info") , 0); 82 | } 83 | 84 | if (IsPathFile("GameData/Global/Objects/Object5.obj")){ 85 | OmegaTechGameObjects.Object5 = LoadModel("GameData/Global/Objects/Object5.obj"); 86 | OmegaTechGameObjects.Object5Texture = LoadTexture("GameData/Global/Objects/Object5Texture.png"); 87 | OmegaTechGameObjects.Object5Icon = LoadTexture("GameData/Global/Objects/Object5Icon.png"); 88 | OmegaTechGameObjects.Object5.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = OmegaTechGameObjects.Object5Texture; 89 | OmegaTechGameObjects.Object5Owned = false; 90 | OmegaTechGameObjects.Object5Name = WSplitValue(LoadFile("GameData/Global/Objects/Object5.info") , 0); 91 | } 92 | } 93 | 94 | static int SelectedObject = 1; 95 | 96 | void UpdateObjectBar(){ 97 | 98 | DrawTextureEx(OmegaTechGameObjects.ObjectBar, {10, GetScreenHeight() - 5 - (32 * 3)} , 0 , 3, WHITE); 99 | 100 | DrawRectangleLines(10 + 2 + ((SelectedObject - 1) * 96) - ((SelectedObject * 3)) , GetScreenHeight() - 5 - (32 * 3) , 32*3, 32*3, WHITE); 101 | 102 | if (OmegaTechGameObjects.Object1Owned){ 103 | DrawTextureEx(OmegaTechGameObjects.Object1Icon, {10, GetScreenHeight() - 5 - (32 * 3)} , 0 , 3, WHITE); 104 | if (SelectedObject == 1)DrawTextEx(OmegaTechGameObjects.BarFont, TextFormat("%ls" , OmegaTechGameObjects.Object1Name.c_str() ),{ 10, (GetScreenHeight() - 5 - (32 * 3)) - 20 } , 20 , 1, WHITE); 105 | } 106 | 107 | if (OmegaTechGameObjects.Object2Owned){ 108 | DrawTextureEx(OmegaTechGameObjects.Object2Icon, {10 + (32 * 3), GetScreenHeight() - 5 - (32 * 3)} , 0 , 3, WHITE); 109 | if (SelectedObject == 2)DrawTextEx(OmegaTechGameObjects.BarFont, TextFormat("%ls" , OmegaTechGameObjects.Object2Name.c_str() ),{ 10 + 96, (GetScreenHeight() - 5 - (32 * 3)) - 20 } , 20 , 1, WHITE); 110 | } 111 | 112 | if (OmegaTechGameObjects.Object3Owned){ 113 | DrawTextureEx(OmegaTechGameObjects.Object3Icon, {10 + 96 * 2, GetScreenHeight() - 5 - (32 * 3)} , 0 , 3, WHITE); 114 | if (SelectedObject == 3)DrawTextEx(OmegaTechGameObjects.BarFont, TextFormat("%ls" , OmegaTechGameObjects.Object3Name.c_str() ),{ 10 + 96 * 2, (GetScreenHeight() - 5 - (32 * 3)) - 20 } , 20 , 1, WHITE); 115 | } 116 | 117 | if (OmegaTechGameObjects.Object4Owned){ 118 | DrawTextureEx(OmegaTechGameObjects.Object4Icon, {10+ 96 * 3, GetScreenHeight() - 5 - (32 * 3)} , 0 , 3, WHITE); 119 | if (SelectedObject == 4)DrawTextEx(OmegaTechGameObjects.BarFont, TextFormat("%ls" , OmegaTechGameObjects.Object4Name.c_str() ),{ 10 + 96 * 3, (GetScreenHeight() - 5 - (32 * 3)) - 20 } , 20 , 1, WHITE); 120 | } 121 | 122 | if (OmegaTechGameObjects.Object5Owned){ 123 | DrawTextureEx(OmegaTechGameObjects.Object5Icon, {10+ 96 * 4, GetScreenHeight() - 5 - (32 * 3)} , 0 , 3, WHITE); 124 | if (SelectedObject == 5)DrawTextEx(OmegaTechGameObjects.BarFont, TextFormat("%ls" , OmegaTechGameObjects.Object5Name.c_str() ),{ 10 + 96 * 4, (GetScreenHeight() - 5 - (32 * 3)) - 20 } , 20 , 1, WHITE); 125 | } 126 | 127 | if (IsKeyPressed(KEY_LEFT)){ 128 | if (SelectedObject != 1) SelectedObject --; 129 | } 130 | if (IsKeyPressed(KEY_RIGHT)){ 131 | if (SelectedObject != 8) SelectedObject ++; 132 | } 133 | 134 | if (GetMouseWheelMove() != 0){ 135 | if (GetMouseWheelMove() < 0){ 136 | if (SelectedObject != 8)SelectedObject ++; 137 | } 138 | else { 139 | if (SelectedObject != 1)SelectedObject --; 140 | } 141 | } 142 | 143 | if (IsGamepadAvailable(0)){ 144 | if (IsGamepadButtonPressed(0 , GAMEPAD_BUTTON_RIGHT_TRIGGER_1)){ 145 | if (SelectedObject != 8) SelectedObject ++; 146 | } 147 | if (IsGamepadButtonPressed(0 , GAMEPAD_BUTTON_LEFT_TRIGGER_1)){ 148 | if (SelectedObject != 1) SelectedObject --; 149 | } 150 | } 151 | 152 | } -------------------------------------------------------------------------------- /Source/PPGIO.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "raylib.h" 8 | 9 | using namespace std; 10 | 11 | wstring LoadFile(const char *Path) 12 | { 13 | wstring Data; 14 | wifstream OutFile; 15 | OutFile.open(Path); 16 | OutFile >> Data; 17 | return Data; 18 | } 19 | 20 | float ToFloat(wstring Data) 21 | { 22 | string s(Data.begin(), Data.end()); 23 | float Out = stof(s); 24 | return Out; 25 | } 26 | 27 | 28 | int GetWDLSize(wstring WData , wstring Extra) 29 | { 30 | int Out = 0; 31 | wstring Data = WData + Extra; 32 | for (int i = 0; i <= WData.size() + Extra.size(); i++) 33 | { 34 | if (Data[i] == ':') 35 | { 36 | Out++; 37 | } 38 | } 39 | return Out; 40 | } 41 | 42 | 43 | 44 | // Weird Optimizations 45 | static wstring ReadValueOut = L""; 46 | 47 | auto WReadValue(wstring Data, int Start, int End) 48 | { // Reads Value from (Start to End) 49 | ReadValueOut = L""; 50 | for (int i = Start; i <= End; i++) 51 | { 52 | ReadValueOut += Data[i]; 53 | } 54 | return ReadValueOut; 55 | } 56 | 57 | static int SVPlaceCounter = 0; 58 | static int SVStart = 0; 59 | static int SVEnd = 0; 60 | 61 | auto WSplitValue(wstring Data, int Place) 62 | { 63 | SVPlaceCounter = 0; 64 | SVStart = 0; 65 | SVEnd = 0; 66 | 67 | if (Place == 0) 68 | { 69 | for (int i = 0; i <= Data.size(); i++) 70 | { 71 | if (Data[i] == L':' || i == Data.size()) 72 | { 73 | SVEnd = i - 1; 74 | break; 75 | } 76 | } 77 | } 78 | else 79 | { 80 | Place = Place; 81 | SVPlaceCounter = 1; 82 | for (int i = 0; i <= Data.size(); i++) 83 | { 84 | if (SVPlaceCounter == Place) 85 | { 86 | SVStart = i + 1; 87 | for (int x = i + 1; x <= Data.size(); x++) 88 | { 89 | if (Data[x] == L':' || x == Data.size()) 90 | { 91 | SVEnd = x - 1; 92 | break; 93 | } 94 | } 95 | } 96 | if (Data[i] == L':') 97 | { 98 | SVPlaceCounter++; 99 | } 100 | } 101 | } 102 | 103 | return WReadValue(Data, SVStart, SVEnd); 104 | } 105 | 106 | auto PullConfigValue(const char *Path, int ValueIndex) 107 | { 108 | 109 | wstring Data = LoadFile(Path); 110 | int Counter = 0; 111 | bool KillLoop = false; 112 | 113 | int Value = 0; 114 | int Place = 1; 115 | 116 | for (int i = 0; i <= Data.size(); i++) 117 | { 118 | 119 | if (Counter == ValueIndex) 120 | { 121 | for (int x = i; x <= Data.size(); x++) 122 | { 123 | switch (Data[x]) 124 | { 125 | case L'0': 126 | Value = Value * Place; 127 | if (Place != 10) 128 | Place = Place * 10; 129 | break; 130 | case L'1': 131 | Value = Value * Place; 132 | if (Place != 10) 133 | Place = Place * 10; 134 | Value += 1; 135 | break; 136 | case L'2': 137 | Value = Value * Place; 138 | if (Place != 10) 139 | Place = Place * 10; 140 | Value += 2; 141 | break; 142 | case L'3': 143 | Value = Value * Place; 144 | if (Place != 10) 145 | Place = Place * 10; 146 | Value += 3; 147 | break; 148 | case L'4': 149 | Value = Value * Place; 150 | if (Place != 10) 151 | Place = Place * 10; 152 | Value += 4; 153 | break; 154 | case L'5': 155 | Value = Value * Place; 156 | if (Place != 10) 157 | Place = Place * 10; 158 | Value += 5; 159 | break; 160 | case L'6': 161 | Value = Value * Place; 162 | if (Place != 10) 163 | Place = Place * 10; 164 | Value += 6; 165 | break; 166 | case L'7': 167 | Value = Value * Place; 168 | if (Place != 10) 169 | Place = Place * 10; 170 | Value += 7; 171 | break; 172 | case L'8': 173 | Value = Value * Place; 174 | if (Place != 10) 175 | Place = Place * 10; 176 | Value += 8; 177 | break; 178 | case L'9': 179 | Value = Value * Place; 180 | if (Place != 10) 181 | Place = Place * 10; 182 | Value += 9; 183 | break; 184 | } 185 | 186 | if (Data[x] == L'|') 187 | { 188 | KillLoop = true; 189 | break; 190 | } 191 | } 192 | } 193 | if (Data[i] == L'|') 194 | { 195 | Counter++; 196 | } 197 | 198 | if (KillLoop) 199 | break; 200 | } 201 | 202 | return Value; 203 | } 204 | 205 | bool GetCollision(int x, int y , int w, int h, int x2 , int y2 , int w2 , int h2){ 206 | if( y+h <= y2 ) 207 | { 208 | return false; 209 | } 210 | 211 | if( y >= y2+h2 ) 212 | { 213 | return false; 214 | } 215 | 216 | if( x+w <= x2 ) 217 | { 218 | return false; 219 | } 220 | 221 | if( x >= x2+w2 ) 222 | { 223 | return false; 224 | } 225 | 226 | return true; 227 | 228 | } 229 | 230 | class Input{ 231 | public: 232 | bool InteractPressed; 233 | bool InteractDown; 234 | bool TextButton; 235 | 236 | void UpdateInputs(){ 237 | if (IsGamepadAvailable(0)){ 238 | if (IsGamepadButtonDown(0 , GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)){ 239 | InteractDown = true; 240 | } 241 | else { 242 | InteractDown = false; 243 | } 244 | if (IsGamepadButtonPressed(0 , GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)){ 245 | InteractPressed = true; 246 | } 247 | else { 248 | InteractPressed = false; 249 | } 250 | if (IsGamepadButtonPressed(0 , GAMEPAD_BUTTON_RIGHT_FACE_DOWN)){ 251 | TextButton = true; 252 | } 253 | else { 254 | TextButton = false; 255 | } 256 | } 257 | else { 258 | if (IsMouseButtonDown(0)){ 259 | InteractDown = true; 260 | } 261 | else { 262 | InteractDown = false; 263 | } 264 | 265 | if (IsMouseButtonPressed(0)){ 266 | InteractPressed = true; 267 | } 268 | else { 269 | InteractPressed = false; 270 | } 271 | 272 | if (IsKeyPressed(KEY_SPACE)){ 273 | TextButton = true; 274 | } 275 | else { 276 | TextButton = false; 277 | } 278 | } 279 | } 280 | }; 281 | 282 | static Input OmegaInputController; 283 | 284 | #ifdef __linux__ 285 | 286 | void Rumble(int duration){ 287 | 288 | } 289 | 290 | #endif 291 | -------------------------------------------------------------------------------- /Source/Parasite/ParasiteScript.hpp: -------------------------------------------------------------------------------- 1 | #include "ParasiteScriptData.hpp" 2 | 3 | 4 | #define RedText "\033[4;31m" 5 | #define GreenText "\033[1;32m" 6 | #define BlueText "\033[1;34m" 7 | #define FadeColorText "\033[1;37m" 8 | 9 | 10 | auto ParasiteScriptLoadFile(const char* Path){ 11 | std::ifstream Input(Path); 12 | std::stringstream sstr; 13 | 14 | while(Input >> sstr.rdbuf()); 15 | 16 | return sstr.str(); 17 | } 18 | 19 | void ParasiteScriptTFlagWipe(){ 20 | for (int i = 0 ; i <= MaxTFlag - 1; i++){ 21 | ToggleFlags[i].Value = 0; 22 | } 23 | } 24 | 25 | void ParasiteScriptInit(){ 26 | ParasiteScriptCoreData.LesserFlag = false; 27 | ParasiteScriptCoreData.GreaterFlag = false; 28 | ParasiteScriptCoreData.EqualFlag = false; 29 | ParasiteScriptCoreData.NotEqualFlag = false; 30 | 31 | ParasiteScriptCoreData.CompareFlag = false; 32 | ParasiteScriptCoreData.ContinueFlag = true; 33 | ParasiteScriptCoreData.ErrorFlag = false; 34 | 35 | ParasiteScriptCoreData.ReturnLine = 0; 36 | ParasiteScriptCoreData.Line[0] = '\0'; 37 | 38 | for (int i = 0; i <= ParasiteScriptCoreData.ProgramSize; i ++){ 39 | ParasiteScriptCoreData.Line[i] = ""; 40 | } 41 | 42 | ParasiteScriptCoreData.ProgramSize = 0; 43 | ParasiteScriptCoreData.TextSize = 20; 44 | 45 | 46 | for (int i = 0 ; i <= MaxVaribles - 1; i++){ 47 | VaribleMemory[i].IValue = 0; 48 | } 49 | } 50 | 51 | auto SplitValue(string Data , int Place ){ 52 | string Out; 53 | int PlaceCounter = 0; 54 | 55 | int Start = 0; 56 | int End = 0; 57 | 58 | if (Place == 0){ 59 | for (int i = 0 ; i <= Data.size() ; i ++){ 60 | if (Data[i] == ' ' || i == Data.size()){ 61 | End = i - 1; 62 | break; 63 | } 64 | } 65 | } 66 | else { 67 | Place = Place; 68 | PlaceCounter = 1; 69 | for (int i = 0 ; i <= Data.size() ; i ++){ 70 | if (PlaceCounter == Place){ 71 | Start = i + 1; 72 | for (int x = i+1 ; x <= Data.size(); x++){ 73 | if (Data[x] == ' ' || x == Data.size()){ 74 | End = x - 1; 75 | break; 76 | } 77 | } 78 | } 79 | if (Data[i] == ' '){ 80 | PlaceCounter ++; 81 | } 82 | } 83 | } 84 | 85 | Out = ReadValue(Data , Start , End); 86 | 87 | return Out; 88 | } 89 | 90 | 91 | auto StringToInt(string Data){ 92 | int Out = 0; 93 | int Place = 1; 94 | for (int i = Data.size() ; i >= 0; i--){ 95 | 96 | switch (Data[i]){ 97 | case '1': 98 | Out += 1 * Place; 99 | Place = Place * 10; 100 | break; 101 | case '2': 102 | Out += 2 * Place; 103 | Place = Place * 10; 104 | break; 105 | case '3': 106 | Out += 3 * Place; 107 | Place = Place * 10; 108 | break; 109 | case '4': 110 | Out += 4 * Place; 111 | Place = Place * 10; 112 | break; 113 | case '5': 114 | Out += 5 * Place; 115 | Place = Place * 10; 116 | break; 117 | case '6': 118 | Out += 6 * Place; 119 | Place = Place * 10; 120 | break; 121 | case '7': 122 | Out += 7 * Place; 123 | Place = Place * 10; 124 | break; 125 | case '8': 126 | Out += 8 * Place; 127 | Place = Place * 10; 128 | break; 129 | case '9': 130 | Out += 9 * Place; 131 | Place = Place * 10; 132 | break; 133 | case '0': 134 | Place = Place * 10; 135 | break; 136 | case '-': 137 | Out = Out * -1; 138 | break; 139 | } 140 | 141 | } 142 | 143 | return Out; 144 | } 145 | 146 | auto StringToChar(string Data){ 147 | char Out[] = ""; 148 | for (int i = 0 ; i <= Data.size(); i++){ 149 | switch (Data[i]){ 150 | case '1': 151 | memcpy(Out , "1" , 1); 152 | break; 153 | } 154 | } 155 | 156 | return Out; 157 | } 158 | 159 | auto ScanVaribleMemory(string VaribleName){ 160 | bool Found = false; 161 | for (int x = 0 ; x <= VaribleCounter; x++){ 162 | if (VaribleMemory[x].Name == VaribleName){ 163 | Found = true; 164 | } 165 | } 166 | return Found; 167 | } 168 | 169 | int PullIntFromMemory(string VaribleName){ 170 | bool Found = false; 171 | for (int x = 0 ; x <= VaribleCounter; x++){ 172 | if (VaribleMemory[x].Name == VaribleName){ 173 | Found = true; 174 | return VaribleMemory[x].IValue; 175 | } 176 | } 177 | if (!Found){ 178 | cout << "Error Varible Not Declared: " << VaribleName << "\n"; 179 | ParasiteScriptCoreData.ErrorFlag = true; 180 | return 0; 181 | } 182 | } 183 | 184 | string PullStrFromMemory(string VaribleName){ 185 | bool Found = false; 186 | for (int x = 0 ; x <= VaribleCounter; x++){ 187 | if (VaribleMemory[x].Name == VaribleName){ 188 | Found = true; 189 | return VaribleMemory[x].Value; 190 | } 191 | } 192 | if (!Found){ 193 | ParasiteScriptCoreData.ErrorFlag = true; 194 | return ""; 195 | } 196 | } 197 | 198 | void StoreIntToMemory(string VaribleName, int Value){ 199 | if (ScanVaribleMemory(VaribleName)){ 200 | for (int x = 0 ; x <= VaribleCounter; x++){ 201 | if (VaribleMemory[x].Name == VaribleName){ 202 | VaribleMemory[x].IValue = Value; 203 | } 204 | } 205 | } 206 | } 207 | 208 | void StoreStrtoMemory(string VaribleName, string Value){ 209 | for (int x = 0 ; x <= VaribleCounter; x++){ 210 | if (VaribleMemory[x].Name == VaribleName){ 211 | VaribleMemory[x].Value = Value; 212 | } 213 | } 214 | } 215 | 216 | string RemoveSpaces(string Data) 217 | { 218 | string OutData = ""; 219 | 220 | for (int i = 0 ; i <= Data.size() ; i ++){ 221 | if (Data[i] != ' '){ 222 | OutData[i] = Data[i]; 223 | } 224 | } 225 | 226 | return OutData; 227 | } 228 | 229 | int ScanSpaces(string Data){ 230 | int Spaces = 0; 231 | 232 | for (int i = 0 ; i <= Data.size() ; i ++){ 233 | if (Data[i] != ' '){ 234 | Spaces ++; 235 | } 236 | } 237 | 238 | return Spaces; 239 | } 240 | 241 | bool IsNumber(const string& s) 242 | { 243 | for (char const &ch : s) { 244 | if (isdigit(ch) == 0) 245 | return false; 246 | } 247 | return true; 248 | } 249 | 250 | 251 | void LoadScript(const char *ScriptPath){ // Loads Script 252 | istringstream ProgramData(ParasiteScriptLoadFile(ScriptPath)); 253 | string CurrentLine; 254 | 255 | while (getline(ProgramData, CurrentLine)) { 256 | 257 | if (ReadValue(CurrentLine, 0 , 0) == ":"){ 258 | JumpPoints[JumpPointCounter].Name = ReadValue(CurrentLine, 1 , CurrentLine.size() - 1); 259 | JumpPoints[JumpPointCounter].LineNumber = ParasiteScriptCoreData.LineCounter; 260 | JumpPointCounter ++; 261 | } 262 | if (ReadValue(CurrentLine, 0 , 0) == " "){ 263 | int SpaceCounter = 0; 264 | for (int i = 0 ; i <= CurrentLine.size() ; i ++){ 265 | if (ReadValue(CurrentLine, i , i) == " ")SpaceCounter ++; 266 | else { 267 | break; 268 | } 269 | } 270 | string Temp = ReadValue(CurrentLine, SpaceCounter , CurrentLine.size() - 1); 271 | CurrentLine = Temp; 272 | } 273 | ParasiteScriptCoreData.Line[ParasiteScriptCoreData.LineCounter] = CurrentLine; 274 | ParasiteScriptCoreData.LineCounter ++; 275 | 276 | 277 | } 278 | ParasiteScriptCoreData.ProgramSize = ParasiteScriptCoreData.LineCounter; 279 | 280 | ParasiteScriptCoreData.LineCounter = 0; 281 | 282 | } 283 | 284 | static int TimeDelay = 0; 285 | 286 | auto CycleInstruction(){ 287 | if (TimeDelay == 0){ 288 | if (ParasiteScriptCoreData.LineCounter != ParasiteScriptCoreData.ProgramSize){ 289 | 290 | bool FoundInstruction = false; 291 | 292 | string Instruction = ParasiteScriptCoreData.Line[ParasiteScriptCoreData.LineCounter]; 293 | 294 | if (ParasiteScriptCoreData.ErrorFlag){ 295 | cout << "Error Command: -->" << ParasiteScriptCoreData.Line[ParasiteScriptCoreData.LineCounter - 1] << "<--\n"; 296 | exit(0); 297 | } 298 | 299 | if (SplitValue(Instruction, 0 ) == "end"){ 300 | FoundInstruction = true; 301 | ParasiteScriptCoreData.ContinueFlag = true; 302 | } 303 | 304 | if (ParasiteScriptCoreData.ContinueFlag && SplitValue(Instruction, 0) != "//"){ 305 | for (int i = 0 ; i <= ScanSpaces(Instruction); i ++){ 306 | if (SplitValue(Instruction, i) == "+"){ 307 | string Part1 = ""; 308 | string Part2 = ""; 309 | bool Found = false; 310 | int SpaceCounter = 0 ; 311 | if (!IsNumber(SplitValue(Instruction, i-1))){ 312 | if (IsNumber(SplitValue(Instruction, i+1))){ 313 | int Value = StringToInt(SplitValue(Instruction, i+1)); 314 | int Value1 = PullIntFromMemory(SplitValue(Instruction, i-1)); 315 | StoreIntToMemory(SplitValue(Instruction, i-1) , Value1 + Value); 316 | } 317 | else{ 318 | int Value = PullIntFromMemory(SplitValue(Instruction, i+1)); 319 | StoreIntToMemory(SplitValue(Instruction, i-1) , PullIntFromMemory(SplitValue(Instruction, i-1)) + Value); 320 | } 321 | 322 | for (int i = 0 ; i <= Instruction.size(); i++){ 323 | if (Instruction[i] == '+'){ 324 | Part1 = ReadValue(Instruction , 0 , i - 1); 325 | Found = true; 326 | } 327 | if (Found){ 328 | if (Instruction[i] == ' '){ 329 | SpaceCounter ++; 330 | if (SpaceCounter == 2){ 331 | Part2 = ReadValue(Instruction , i + 1, Instruction.size() - 1); 332 | Part2 += " "; 333 | } 334 | } 335 | } 336 | } 337 | } 338 | else { 339 | int Value = StringToInt(SplitValue(Instruction, i-1)) + StringToInt(SplitValue(Instruction, i+1)); 340 | 341 | for (int i = 0 ; i <= Instruction.size(); i++){ 342 | if (Instruction[i] == '+'){ 343 | Part1 = ReadValue(Instruction , 0 , i - 3); 344 | stringstream ss; 345 | ss << Value; 346 | Part1 += ss.str(); 347 | Part1 += " "; 348 | Found = true; 349 | } 350 | if (Found){ 351 | if (Instruction[i] == ' '){ 352 | SpaceCounter ++; 353 | if (SpaceCounter == 2){ 354 | Part2 = ReadValue(Instruction , i + 1, Instruction.size()); 355 | Part2 += " "; 356 | } 357 | } 358 | } 359 | } 360 | } 361 | 362 | 363 | Instruction = '\0'; 364 | Instruction = Part1 + Part2; 365 | ParasiteScriptCoreData.Line[ParasiteScriptCoreData.LineCounter] = Instruction; 366 | 367 | } 368 | if (SplitValue(Instruction, i) == "-"){ 369 | string Part1 = ""; 370 | string Part2 = ""; 371 | bool Found = false; 372 | int SpaceCounter = 0 ; 373 | if (!IsNumber(SplitValue(Instruction, i-1))){ 374 | if (IsNumber(SplitValue(Instruction, i+1))){ 375 | int Value = StringToInt(SplitValue(Instruction, i+1)); 376 | int Value1 = PullIntFromMemory(SplitValue(Instruction, i-1)); 377 | StoreIntToMemory(SplitValue(Instruction, i-1) , Value1 - Value); 378 | } 379 | else{ 380 | int Value = PullIntFromMemory(SplitValue(Instruction, i+1)); 381 | StoreIntToMemory(SplitValue(Instruction, i-1) , PullIntFromMemory(SplitValue(Instruction, i-1)) - Value); 382 | } 383 | 384 | for (int i = 0 ; i <= Instruction.size(); i++){ 385 | if (Instruction[i] == '-'){ 386 | Part1 = ReadValue(Instruction , 0 , i - 1); 387 | Found = true; 388 | } 389 | if (Found){ 390 | if (Instruction[i] == ' '){ 391 | SpaceCounter ++; 392 | if (SpaceCounter == 2){ 393 | Part2 = ReadValue(Instruction , i + 1, Instruction.size() - 1); 394 | Part2 += " "; 395 | } 396 | } 397 | } 398 | } 399 | } 400 | else { 401 | int Value = StringToInt(SplitValue(Instruction, i-1)) - StringToInt(SplitValue(Instruction, i+1)); 402 | 403 | for (int i = 0 ; i <= Instruction.size(); i++){ 404 | if (Instruction[i] == '-'){ 405 | Part1 = ReadValue(Instruction , 0 , i - 3); 406 | stringstream ss; 407 | ss << Value; 408 | Part1 += ss.str(); 409 | Part1 += " "; 410 | Found = true; 411 | } 412 | if (Found){ 413 | if (Instruction[i] == ' '){ 414 | SpaceCounter ++; 415 | if (SpaceCounter == 2){ 416 | Part2 = ReadValue(Instruction , i + 1, Instruction.size()); 417 | Part2 += " "; 418 | } 419 | } 420 | } 421 | } 422 | } 423 | 424 | 425 | Instruction = '\0'; 426 | Instruction = Part1 + Part2; 427 | ParasiteScriptCoreData.Line[ParasiteScriptCoreData.LineCounter] = Instruction; 428 | } 429 | 430 | if (SplitValue(Instruction, i) == "*"){ 431 | string Part1 = ""; 432 | string Part2 = ""; 433 | bool Found = false; 434 | int SpaceCounter = 0 ; 435 | if (!IsNumber(SplitValue(Instruction, i-1))){ 436 | if (IsNumber(SplitValue(Instruction, i+1))){ 437 | int Value = StringToInt(SplitValue(Instruction, i+1)); 438 | int Value1 = PullIntFromMemory(SplitValue(Instruction, i-1)); 439 | StoreIntToMemory(SplitValue(Instruction, i-1) , Value1 * Value); 440 | } 441 | else{ 442 | int Value = PullIntFromMemory(SplitValue(Instruction, i+1)); 443 | StoreIntToMemory(SplitValue(Instruction, i-1) , PullIntFromMemory(SplitValue(Instruction, i-1)) * Value); 444 | } 445 | 446 | for (int i = 0 ; i <= Instruction.size(); i++){ 447 | if (Instruction[i] == '*'){ 448 | Part1 = ReadValue(Instruction , 0 , i - 1); 449 | Found = true; 450 | } 451 | if (Found){ 452 | if (Instruction[i] == ' '){ 453 | SpaceCounter ++; 454 | if (SpaceCounter == 2){ 455 | Part2 = ReadValue(Instruction , i + 1, Instruction.size() - 1); 456 | Part2 += " "; 457 | } 458 | } 459 | } 460 | } 461 | } 462 | else { 463 | int Value = StringToInt(SplitValue(Instruction, i-1)) * StringToInt(SplitValue(Instruction, i+1)); 464 | 465 | for (int i = 0 ; i <= Instruction.size(); i++){ 466 | if (Instruction[i] == '*'){ 467 | Part1 = ReadValue(Instruction , 0 , i - 3); 468 | stringstream ss; 469 | ss << Value; 470 | Part1 += ss.str(); 471 | Part1 += " "; 472 | cout << Part1 << "\n"; 473 | Found = true; 474 | } 475 | if (Found){ 476 | if (Instruction[i] == ' '){ 477 | SpaceCounter ++; 478 | if (SpaceCounter == 2){ 479 | Part2 = ReadValue(Instruction , i + 1, Instruction.size()); 480 | Part2 += " "; 481 | } 482 | } 483 | } 484 | } 485 | } 486 | 487 | 488 | Instruction = '\0'; 489 | Instruction = Part1 + Part2; 490 | ParasiteScriptCoreData.Line[ParasiteScriptCoreData.LineCounter] = Instruction; 491 | 492 | } 493 | 494 | if (SplitValue(Instruction, i) == "/"){ 495 | string Part1 = ""; 496 | string Part2 = ""; 497 | bool Found = false; 498 | int SpaceCounter = 0 ; 499 | if (!IsNumber(SplitValue(Instruction, i-1))){ 500 | if (IsNumber(SplitValue(Instruction, i+1))){ 501 | int Value = StringToInt(SplitValue(Instruction, i+1)); 502 | int Value1 = PullIntFromMemory(SplitValue(Instruction, i-1)); 503 | StoreIntToMemory(SplitValue(Instruction, i-1) , Value1 / Value); 504 | } 505 | else{ 506 | int Value = PullIntFromMemory(SplitValue(Instruction, i+1)); 507 | StoreIntToMemory(SplitValue(Instruction, i-1) , PullIntFromMemory(SplitValue(Instruction, i-1)) / Value); 508 | } 509 | 510 | for (int i = 0 ; i <= Instruction.size(); i++){ 511 | if (Instruction[i] == '/'){ 512 | Part1 = ReadValue(Instruction , 0 , i - 1); 513 | Found = true; 514 | } 515 | if (Found){ 516 | if (Instruction[i] == ' '){ 517 | SpaceCounter ++; 518 | if (SpaceCounter == 2){ 519 | Part2 = ReadValue(Instruction , i + 1, Instruction.size() - 1); 520 | Part2 += " "; 521 | } 522 | } 523 | } 524 | } 525 | } 526 | else { 527 | int Value = StringToInt(SplitValue(Instruction, i-1)) / StringToInt(SplitValue(Instruction, i+1)); 528 | 529 | for (int i = 0 ; i <= Instruction.size(); i++){ 530 | if (Instruction[i] == '/'){ 531 | Part1 = ReadValue(Instruction , 0 , i - 3); 532 | stringstream ss; 533 | ss << Value; 534 | Part1 += ss.str(); 535 | Part1 += " "; 536 | cout << Part1 << "\n"; 537 | Found = true; 538 | } 539 | if (Found){ 540 | if (Instruction[i] == ' '){ 541 | SpaceCounter ++; 542 | if (SpaceCounter == 2){ 543 | Part2 = ReadValue(Instruction , i + 1, Instruction.size()); 544 | Part2 += " "; 545 | } 546 | } 547 | } 548 | } 549 | } 550 | 551 | 552 | Instruction = '\0'; 553 | Instruction = Part1 + Part2; 554 | ParasiteScriptCoreData.Line[ParasiteScriptCoreData.LineCounter] = Instruction; 555 | 556 | } 557 | } 558 | 559 | if (SplitValue(Instruction, 1) == "="){ 560 | FoundInstruction = true; 561 | if (IsNumber(SplitValue(Instruction, 2))){ 562 | StoreIntToMemory(SplitValue(Instruction, 0) , StringToInt(SplitValue(Instruction, 2))); 563 | } 564 | else { 565 | int Value = PullIntFromMemory(SplitValue(Instruction, 2)); 566 | StoreIntToMemory(SplitValue(Instruction, 0) , Value); 567 | } 568 | } 569 | 570 | if (SplitValue(Instruction, 1) == "+="){ 571 | FoundInstruction = true; 572 | if (IsNumber(SplitValue(Instruction, 2))){ 573 | int Value = StringToInt(SplitValue(Instruction, 2)); 574 | StoreIntToMemory(SplitValue(Instruction, 0) , PullIntFromMemory(SplitValue(Instruction, 0)) + Value); 575 | } 576 | else{ 577 | int Value = PullIntFromMemory(SplitValue(Instruction, 2)); 578 | StoreIntToMemory(SplitValue(Instruction, 0) , PullIntFromMemory(SplitValue(Instruction, 0)) + Value); 579 | } 580 | } 581 | 582 | if (SplitValue(Instruction, 1) == "-="){ 583 | FoundInstruction = true; 584 | if (IsNumber(SplitValue(Instruction, 2))){ 585 | int Value = StringToInt(SplitValue(Instruction, 2)); 586 | StoreIntToMemory(SplitValue(Instruction, 0) , PullIntFromMemory(SplitValue(Instruction, 0)) - Value); 587 | } 588 | else{ 589 | int Value = PullIntFromMemory(SplitValue(Instruction, 2)); 590 | StoreIntToMemory(SplitValue(Instruction, 0) , PullIntFromMemory(SplitValue(Instruction, 0)) - Value); 591 | } 592 | } 593 | 594 | if (SplitValue(Instruction, 1) == "*="){ 595 | FoundInstruction = true; 596 | if (IsNumber(SplitValue(Instruction, 2))){ 597 | int Value = StringToInt(SplitValue(Instruction, 2)); 598 | StoreIntToMemory(SplitValue(Instruction, 0) , PullIntFromMemory(SplitValue(Instruction, 0)) * Value); 599 | } 600 | else{ 601 | int Value = PullIntFromMemory(SplitValue(Instruction, 2)); 602 | StoreIntToMemory(SplitValue(Instruction, 0) , PullIntFromMemory(SplitValue(Instruction, 0)) * Value); 603 | } 604 | } 605 | 606 | if (SplitValue(Instruction, 1) == "/="){ 607 | FoundInstruction = true; 608 | if (IsNumber(SplitValue(Instruction, 2))){ 609 | int Value = StringToInt(SplitValue(Instruction, 2)); 610 | StoreIntToMemory(SplitValue(Instruction, 0) , PullIntFromMemory(SplitValue(Instruction, 0)) / Value); 611 | } 612 | else{ 613 | int Value = PullIntFromMemory(SplitValue(Instruction, 2)); 614 | StoreIntToMemory(SplitValue(Instruction, 0) , PullIntFromMemory(SplitValue(Instruction, 0)) / Value); 615 | } 616 | } 617 | 618 | if (SplitValue(Instruction, 0 ) == "if"){ 619 | FoundInstruction = true; 620 | 621 | ParasiteScriptCoreData.ContinueFlag = true; 622 | ParasiteScriptCoreData.ElseFlag = false; 623 | 624 | string Operator = SplitValue(Instruction, 2 ); 625 | int Value1 = 0; 626 | int Value2 = 0; 627 | 628 | if (IsNumber(SplitValue(Instruction, 1))){ 629 | Value1 = StringToInt(SplitValue(Instruction, 1 )); 630 | } 631 | else { 632 | Value1 = PullIntFromMemory(SplitValue(Instruction, 1 )); 633 | } 634 | 635 | if (IsNumber(SplitValue(Instruction, 3))){ 636 | Value2 = StringToInt(SplitValue(Instruction, 3 )); 637 | } 638 | else { 639 | Value2 = PullIntFromMemory(SplitValue(Instruction, 3 )); 640 | } 641 | 642 | if (Operator == "=="){ 643 | if (Value1 == Value2){ 644 | ParasiteScriptCoreData.ContinueFlag = true; 645 | } 646 | else { 647 | ParasiteScriptCoreData.ContinueFlag = false; 648 | ParasiteScriptCoreData.ElseFlag = true; 649 | } 650 | } 651 | 652 | if (Operator == ">"){ 653 | if (Value1 > Value2){ 654 | ParasiteScriptCoreData.ContinueFlag = true; 655 | } 656 | else { 657 | ParasiteScriptCoreData.ContinueFlag = false; 658 | ParasiteScriptCoreData.ElseFlag = true; 659 | } 660 | } 661 | 662 | if (Operator == "<"){ 663 | if (Value1 < Value2){ 664 | ParasiteScriptCoreData.ContinueFlag = true; 665 | } 666 | else { 667 | ParasiteScriptCoreData.ContinueFlag = false; 668 | ParasiteScriptCoreData.ElseFlag = true; 669 | } 670 | } 671 | 672 | if (Operator == ">="){ 673 | if (Value1 >= Value2){ 674 | ParasiteScriptCoreData.ContinueFlag = true; 675 | } 676 | else { 677 | ParasiteScriptCoreData.ContinueFlag = false; 678 | ParasiteScriptCoreData.ElseFlag = true; 679 | } 680 | } 681 | 682 | if (Operator == "<="){ 683 | if (Value1 >= Value2){ 684 | ParasiteScriptCoreData.ContinueFlag = true; 685 | } 686 | else { 687 | ParasiteScriptCoreData.ContinueFlag = false; 688 | ParasiteScriptCoreData.ElseFlag = true; 689 | } 690 | } 691 | 692 | if (Operator == "!="){ 693 | if (Value1 != Value2){ 694 | ParasiteScriptCoreData.ContinueFlag = true; 695 | } 696 | else { 697 | ParasiteScriptCoreData.ContinueFlag = false; 698 | ParasiteScriptCoreData.ElseFlag = true; 699 | } 700 | } 701 | } 702 | 703 | if (SplitValue(Instruction, 0 ) == "else"){ 704 | FoundInstruction = true; 705 | if (!ParasiteScriptCoreData.ElseFlag){ 706 | ParasiteScriptCoreData.ContinueFlag = false; 707 | } 708 | } 709 | 710 | if (SplitValue(Instruction, 0 ) == "stop"){ 711 | FoundInstruction = true; 712 | exit(0); 713 | } 714 | 715 | if (SplitValue(Instruction, 0 ) == "var" ){ 716 | FoundInstruction = true; 717 | VaribleMemory[VaribleCounter].Name = SplitValue(Instruction, 1 ); 718 | 719 | string VaribleData = SplitValue(Instruction, 2 ); 720 | int VaribleType = 0; 721 | 722 | if (ReadValue(VaribleData , 0 , 0) == "'"){ 723 | VaribleType = 1; 724 | } 725 | else { 726 | VaribleType = 0; 727 | } 728 | 729 | if (VaribleType == 1){ 730 | string StoredData = ""; 731 | for (int i = 0 ; i <= VaribleData.size() ; i ++){ 732 | if (ReadValue(VaribleData , i , i) != "'"){ 733 | StoredData += ReadValue(VaribleData , i , i); 734 | } 735 | } 736 | VaribleMemory[VaribleCounter].Value = StoredData; 737 | VaribleMemory[VaribleCounter].IValue = 0; 738 | } 739 | else { 740 | VaribleMemory[VaribleCounter].IValue = StringToInt(VaribleData); 741 | VaribleMemory[VaribleCounter].Value = " "; 742 | } 743 | 744 | VaribleCounter++; 745 | 746 | } 747 | 748 | if (SplitValue(Instruction, 0 ) == "wtflag"){ 749 | ToggleFlags[StringToInt(SplitValue(Instruction, 1 ))].Value = StringToInt(SplitValue(Instruction, 2)); 750 | FoundInstruction = true; 751 | } 752 | 753 | if (SplitValue(Instruction, 0 ) == "rtflag"){ 754 | int Value = ToggleFlags[StringToInt(SplitValue(Instruction, 1 ))].Value; 755 | StoreIntToMemory(SplitValue(Instruction, 2), Value); 756 | FoundInstruction = true; 757 | } 758 | 759 | if (SplitValue(Instruction, 0 ) == "say"){ 760 | OmegaTechTextSystem.Write(ReadValue(Instruction , 4 , Instruction.size() - 1)); 761 | FoundInstruction = true; 762 | } 763 | if (SplitValue(Instruction, 0 ) == "addwdli"){ 764 | string WDLString = SplitValue(Instruction, 1 ); 765 | wstring ws(WDLString.begin(), WDLString.end()); 766 | ExtraWDLInstructions += ws; 767 | FoundInstruction = true; 768 | } 769 | if (SplitValue(Instruction, 0 ) == "clrwdli"){ 770 | ExtraWDLInstructions = L""; 771 | FoundInstruction = true; 772 | } 773 | 774 | if (SplitValue(Instruction, 0 ) == "ownobj"){ 775 | int ObjectId = StringToInt(SplitValue(Instruction, 1)); 776 | 777 | switch (ObjectId){ 778 | case 1: 779 | OmegaTechGameObjects.Object1Owned = true; 780 | break; 781 | case 2: 782 | OmegaTechGameObjects.Object2Owned = true; 783 | break; 784 | case 3: 785 | OmegaTechGameObjects.Object3Owned = true; 786 | break; 787 | case 4: 788 | OmegaTechGameObjects.Object3Owned = true; 789 | break; 790 | case 5: 791 | OmegaTechGameObjects.Object3Owned = true; 792 | break; 793 | } 794 | 795 | FoundInstruction = true; 796 | } 797 | 798 | 799 | if (SplitValue(Instruction, 0 ) == "setscene"){ 800 | SetSceneFlag = true; 801 | SetSceneId = StringToInt(SplitValue(Instruction, 1 )); 802 | FoundInstruction = true; 803 | } 804 | 805 | if (SplitValue(Instruction, 0 ) == "kill"){ 806 | ParasiteScriptCoreData.LineCounter = ParasiteScriptCoreData.ProgramSize; 807 | FoundInstruction = true; 808 | } 809 | if (SplitValue(Instruction, 0 ) == "setcampos"){ 810 | SetCameraFlag = true; 811 | int X = StringToInt(SplitValue(Instruction, 1 )); 812 | int Y = StringToInt(SplitValue(Instruction, 2 )); 813 | int Z = StringToInt(SplitValue(Instruction, 3 )); 814 | SetCameraPos = {float(X),float(Y),float(Z)}; 815 | 816 | FoundInstruction = true; 817 | } 818 | } 819 | } 820 | } 821 | } 822 | -------------------------------------------------------------------------------- /Source/Parasite/ParasiteScriptData.hpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "../TextSystem.hpp" 12 | 13 | using namespace std; 14 | 15 | #define MaxVaribles 100 16 | #define MaxJumpPoints 45 17 | #define MaxArraySize 1 18 | #define MaxTFlag 100 19 | #define MaxArrays 1 20 | 21 | static int VaribleCounter = 0; 22 | static int JumpPointCounter = 0; 23 | static int ArrayCounter = 0; 24 | 25 | static wstring ExtraWDLInstructions = L""; 26 | 27 | 28 | 29 | static bool SetSceneFlag = false; 30 | static int SetSceneId = 0; 31 | 32 | static bool SetCameraFlag = false; 33 | static Vector3 SetCameraPos = {0,0,0}; 34 | 35 | typedef struct Memory{ 36 | string Name; 37 | string Value; 38 | int IValue; 39 | }Memory; 40 | 41 | 42 | static Memory VaribleMemory[MaxVaribles]; 43 | 44 | typedef struct ArrMemory{ 45 | string Name; 46 | int Array[MaxArraySize]; 47 | int Size; 48 | }ArrMemory; 49 | 50 | 51 | static ArrMemory ArrayMemory[MaxArrays]; 52 | 53 | typedef struct JumpPoint{ 54 | string Name; 55 | int LineNumber; 56 | }JumpPoint; 57 | 58 | static JumpPoint JumpPoints[MaxJumpPoints]; 59 | 60 | typedef struct Flags{ 61 | bool Value; 62 | }Flags; 63 | 64 | static Flags ToggleFlags[MaxTFlag]; 65 | 66 | 67 | typedef struct ParasiteScriptData{ 68 | istringstream ProgramData; 69 | 70 | string Line[1000]; 71 | 72 | int LineCounter; 73 | int ProgramSize; 74 | 75 | bool CompareFlag; 76 | 77 | bool EqualFlag; 78 | bool GreaterFlag; 79 | bool LesserFlag; 80 | bool NotEqualFlag; 81 | bool ContinueFlag; 82 | bool ElseFlag; 83 | bool ErrorFlag; 84 | 85 | int ReturnLine; 86 | int TextSize; 87 | 88 | 89 | }ParasiteScriptData; 90 | 91 | static ParasiteScriptData ParasiteScriptCoreData; 92 | 93 | 94 | -------------------------------------------------------------------------------- /Source/ParticleDemon/ParticleDemon.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "raylib.h" 6 | 7 | using namespace std; 8 | 9 | 10 | 11 | static int ExplosionEffect = 1; 12 | 13 | static int TrailEffect = 2; 14 | 15 | static int RainEffect = 3; 16 | 17 | 18 | #define MaxParticles 50 19 | 20 | 21 | 22 | class ParticleSystem{ 23 | public: 24 | Vector2 ParticleArray[MaxParticles]; 25 | Vector2 ParticleVelocity[MaxParticles]; 26 | int ParticleSize[MaxParticles]; 27 | int Colour[MaxParticles]; 28 | 29 | int ParticleCounter = 0; 30 | 31 | void DeleteEffect(){ 32 | for (int i = 0 ; i <= MaxParticles - 1; i ++){ 33 | ParticleArray[i].x = 0; 34 | ParticleArray[i].y = 0; 35 | ParticleVelocity[i].x = 0; 36 | ParticleVelocity[i].y = 0; 37 | ParticleSize[i] = 0; 38 | ParticleCounter = 0; 39 | } 40 | } 41 | 42 | void TriggerEffect(Vector2 Start , int EffectType){ 43 | if (EffectType == ExplosionEffect){ 44 | for (int i = 0 ; i <= MaxParticles - 1; i ++){ 45 | ParticleArray[i].x = Start.x + GetRandomValue(-20, 20); 46 | ParticleArray[i].y = Start.y + GetRandomValue(-20, 20); 47 | ParticleVelocity[i].x = GetRandomValue(-20, 20); 48 | ParticleVelocity[i].y = GetRandomValue(-20, 20); 49 | 50 | ParticleSize[i] = GetRandomValue(0, 10); 51 | Colour[i] = GetRandomValue(0, 4); 52 | 53 | } 54 | } 55 | if (EffectType == TrailEffect){ 56 | 57 | ParticleArray[ParticleCounter].x = Start.x + GetRandomValue(1, 1); 58 | ParticleArray[ParticleCounter].y = Start.y + GetRandomValue(-20, 1); 59 | ParticleVelocity[ParticleCounter].x = GetRandomValue(-10, -15); 60 | ParticleVelocity[ParticleCounter].y = GetRandomValue(-4, 1); 61 | 62 | ParticleSize[ParticleCounter] = GetRandomValue(0, 10); 63 | Colour[ParticleCounter] = GetRandomValue(0, 4); 64 | 65 | ParticleCounter ++; 66 | 67 | 68 | if (ParticleCounter == MaxParticles){ 69 | DeleteEffect(); 70 | } 71 | } 72 | if (EffectType == RainEffect){ 73 | 74 | ParticleArray[ParticleCounter].x = Start.x + GetRandomValue(1, GetScreenWidth()); 75 | ParticleArray[ParticleCounter].y = Start.y; 76 | ParticleVelocity[ParticleCounter].x = 0; 77 | ParticleVelocity[ParticleCounter].y = GetRandomValue(1, 20); 78 | 79 | ParticleSize[ParticleCounter] = GetRandomValue(0, 10); 80 | Colour[ParticleCounter] = 2; 81 | 82 | ParticleCounter ++; 83 | 84 | 85 | if (ParticleCounter == MaxParticles){ 86 | DeleteEffect(); 87 | } 88 | } 89 | } 90 | 91 | void Update(int XOff , int YOff){ 92 | for (int i = 0 ; i <= MaxParticles - 1; i ++){ 93 | 94 | 95 | switch (Colour[i]) 96 | { 97 | case 0: 98 | //DrawCircleLines(ParticleArray[i].x - XOff , ParticleArray[i].y - YOff , ParticleSize[i] , RED); 99 | DrawPixel(ParticleArray[i].x - XOff , ParticleArray[i].y - YOff , RED); 100 | break; 101 | case 1: 102 | //DrawCircleLines(ParticleArray[i].x - XOff , ParticleArray[i].y - YOff , ParticleSize[i] , ORANGE); 103 | DrawPixel(ParticleArray[i].x - XOff , ParticleArray[i].y - YOff , ORANGE); 104 | break; 105 | case 2: 106 | DrawPixel(ParticleArray[i].x - XOff , ParticleArray[i].y - YOff , BLUE); 107 | 108 | break; 109 | case 3: 110 | //DrawCircleLines(ParticleArray[i].x - XOff , ParticleArray[i].y - YOff , ParticleSize[i] , YELLOW); 111 | DrawPixel(ParticleArray[i].x - XOff , ParticleArray[i].y - YOff , YELLOW); 112 | break; 113 | case 5: 114 | //DrawCircleLines(ParticleArray[i].x - XOff , ParticleArray[i].y - YOff , ParticleSize[i] , YELLOW); 115 | DrawPixel(ParticleArray[i].x - XOff , ParticleArray[i].y - YOff , BLUE); 116 | break; 117 | 118 | default: 119 | //DrawCircleLines(ParticleArray[i].x - XOff , ParticleArray[i].y - YOff , ParticleSize[i] , WHITE); 120 | DrawPixel(ParticleArray[i].x - XOff , ParticleArray[i].y - YOff , RED); 121 | break; 122 | } 123 | 124 | 125 | //if (ParticleArray[i].x <= 0)DeleteEffect(); 126 | 127 | 128 | ParticleArray[i].x += ParticleVelocity[i].x; 129 | ParticleArray[i].y += ParticleVelocity[i].y; 130 | 131 | ParticleArray[i].x += GetMouseDelta().x; 132 | ParticleArray[i].y += GetMouseDelta().y; 133 | 134 | } 135 | } 136 | }; 137 | -------------------------------------------------------------------------------- /Source/Player.hpp: -------------------------------------------------------------------------------- 1 | #include "raylib.h" 2 | 3 | class Player{ 4 | public: 5 | float Height = 10.0f; 6 | float Width = 2.0f; 7 | 8 | int HeadBob = 0; 9 | int HeadBobDirection = 1; 10 | 11 | int Health = 100; 12 | 13 | float OldX = 0.0f; 14 | float OldY = 0.0f; 15 | float OldZ = 0.0f; 16 | 17 | BoundingBox PlayerBounds; 18 | }; 19 | 20 | static Player OmegaPlayer; -------------------------------------------------------------------------------- /Source/Settings.hpp: -------------------------------------------------------------------------------- 1 | #include "raygui/raygui.h" 2 | #include "raygui/dark.h" 3 | #include 4 | 5 | static bool ShowSettings = false; 6 | static bool Debug = false; 7 | static bool HeadBob = true; 8 | static bool PixelShader = true; 9 | static bool ParticlesEnabled = true; 10 | static bool FPSEnabled = false; 11 | static float ResolutionScale = 1.0f; 12 | 13 | static RenderTexture2D Target; 14 | 15 | 16 | void ToggleSettings(){ 17 | if (ShowSettings){ 18 | ShowSettings = false; 19 | HideCursor(); 20 | DisableCursor(); 21 | } 22 | else { 23 | ShowSettings = true; 24 | ShowCursor(); 25 | EnableCursor(); 26 | } 27 | } 28 | 29 | void UpdateSettings(){ 30 | if (ShowSettings){ 31 | GuiWindowBox((Rectangle){ 20, 20, 300, 400 }, "OmegaTech Developer Settings"); 32 | if (GuiButton((Rectangle){ 40, 50, 80, 40 }, "Toggle Debug")){ 33 | if (Debug){ 34 | Debug = false; 35 | } 36 | else { 37 | Debug = true; 38 | } 39 | } 40 | if (GuiButton((Rectangle){ 40 + 90, 50, 80, 40 }, "Toggle H.B.")){ 41 | if (HeadBob){ 42 | HeadBob = false; 43 | } 44 | else { 45 | HeadBob = true; 46 | } 47 | } 48 | if (GuiButton((Rectangle){ 40 + 90 * 2, 50, 80, 40 }, "Toggle P.S.")){ 49 | if (PixelShader){ 50 | PixelShader = false; 51 | } 52 | else { 53 | PixelShader = true; 54 | } 55 | } 56 | 57 | if (GuiButton((Rectangle){ 40, 50 + 50, 80, 40 }, "Particles")){ 58 | if (ParticlesEnabled){ 59 | ParticlesEnabled = false; 60 | } 61 | else { 62 | ParticlesEnabled = true; 63 | } 64 | } 65 | 66 | if (GuiButton((Rectangle){ 40 + 90, 50 + 50, 80, 40 }, "Show FPS")){ 67 | if (FPSEnabled){ 68 | FPSEnabled = false; 69 | } 70 | else { 71 | FPSEnabled = true; 72 | } 73 | } 74 | 75 | if (GuiButton((Rectangle){ 40 + 90 * 2, 50 + 50, 80, 40 }, "VSync .T")){ 76 | if (IsWindowState(FLAG_VSYNC_HINT)){ 77 | ClearWindowState(FLAG_VSYNC_HINT); 78 | } 79 | else { 80 | SetConfigFlags(FLAG_VSYNC_HINT); 81 | } 82 | } 83 | GuiGroupBox((Rectangle){ 40, 150, 260, 110 }, "Resolution Scale"); 84 | ResolutionScale = GuiSlider((Rectangle){ 90, 160, 120, 40 }, "Internal" , TextFormat("%ipx: %ipx" , int(1280 * ResolutionScale) , int(720* ResolutionScale)), ResolutionScale, 0.0f, 3.0f); 85 | 86 | if (GuiButton((Rectangle){ 90, 210, 120, 20}, "Set")){ 87 | UnloadRenderTexture(Target); 88 | Target = LoadRenderTexture(int(1280 * ResolutionScale) , int(720* ResolutionScale)); 89 | } 90 | 91 | GuiGroupBox((Rectangle){ 40, 150 + 120, 265, 60 }, "Window Size"); 92 | 93 | if (GuiButton((Rectangle){ 50, 150 + 135, 45, 30}, "480p")){ 94 | SetWindowSize(640,480); 95 | } 96 | 97 | if (GuiButton((Rectangle){ 50 + 50, 150 + 135, 45, 30}, "720p")){ 98 | SetWindowSize(1280,720); 99 | } 100 | 101 | if (GuiButton((Rectangle){ 50 + 50 * 2, 150 + 135, 45, 30}, "1080p")){ 102 | SetWindowSize(1980 , 1080); 103 | } 104 | 105 | if (GuiButton((Rectangle){ 50 + 50 * 3, 150 + 135, 45, 30}, "1440p")){ 106 | SetWindowSize(2560,1440); 107 | } 108 | 109 | if (GuiButton((Rectangle){ 50 + 50 * 4, 150 + 135, 45, 30}, "4k")){ 110 | SetWindowSize(3840,2160); 111 | } 112 | } 113 | } 114 | 115 | bool MenuSettings = false; 116 | 117 | bool Spinner003EditMode = false; 118 | int Spinner003Value = 0; 119 | bool Spinner004EditMode = false; 120 | int Spinner004Value = 0; 121 | 122 | bool VSYNCToggle = false; 123 | bool MXAAToggle = false; 124 | 125 | bool MuteToggle = false; 126 | float AudioSlider = 100.0f; 127 | 128 | void ShowMenuSetiings(){ 129 | Rectangle LayoutRecs[15] = { 130 | (Rectangle){ 72, 85, 120, 24 }, 131 | (Rectangle){ 62, 115, 391, 419 }, 132 | (Rectangle){ 71, 145, 374, 200 }, 133 | (Rectangle){ 94, 186, 120, 24 }, 134 | (Rectangle){ 172, 237, 120, 24 }, 135 | (Rectangle){ 171, 278, 120, 24 }, 136 | (Rectangle){ 311, 258, 120, 24 }, 137 | (Rectangle){ 325, 176, 88, 24 }, 138 | (Rectangle){ 325, 214, 88, 24 }, 139 | (Rectangle){ 336, 399, 88, 24 }, 140 | (Rectangle){ 182, 407, 120, 16 }, 141 | (Rectangle){ 72, 361, 374, 85 }, 142 | (Rectangle){ 73, 452, 120, 24 }, 143 | (Rectangle){ 74, 486, 146, 26 }, 144 | (Rectangle){ 268, 475, 140, 28 }, 145 | }; 146 | GuiWindowBox(LayoutRecs[1], "Settings"); 147 | GuiLabel(LayoutRecs[0], "Omega Tech Settings"); 148 | GuiPanel(LayoutRecs[2], "Window"); 149 | if (GuiButton(LayoutRecs[3], "Toggle Fullscreen")) ToggleFullscreen(); 150 | VSYNCToggle = GuiToggle(LayoutRecs[7], "VSync", VSYNCToggle); 151 | MXAAToggle = GuiToggle(LayoutRecs[8], "MXAA x4", MXAAToggle); 152 | 153 | GuiPanel(LayoutRecs[11], "Audio"); 154 | MuteToggle = GuiToggle(LayoutRecs[9], "Mute Audio", MuteToggle); 155 | AudioSlider = GuiSlider(LayoutRecs[10], "Audio Volume", NULL, AudioSlider, 0, 100); 156 | 157 | GuiLabel(LayoutRecs[12], "OMEGATECH ENGINE "); 158 | GuiLabel(LayoutRecs[13], "PixelPhobicGames 2023"); 159 | GuiLabel(LayoutRecs[14], "@EC, JF , ZT , NC , LC"); 160 | 161 | if (VSYNCToggle){ 162 | SetConfigFlags(FLAG_VSYNC_HINT); 163 | } 164 | else { 165 | ClearWindowState(FLAG_VSYNC_HINT); 166 | } 167 | 168 | if (MXAAToggle){ 169 | SetConfigFlags(FLAG_MSAA_4X_HINT); 170 | } 171 | else { 172 | ClearWindowState(FLAG_MSAA_4X_HINT); 173 | } 174 | SetMasterVolume(AudioSlider); 175 | if (MuteToggle){ 176 | SetMasterVolume(0); 177 | } 178 | 179 | } -------------------------------------------------------------------------------- /Source/TextSystem.hpp: -------------------------------------------------------------------------------- 1 | #include "Objects.hpp" 2 | 3 | using namespace std; 4 | 5 | auto ReadValue(string Data , int Start , int End){ // Reads Value from (Start to End) 6 | string Out; 7 | for (int i = Start ; i <= End ; i ++){ 8 | Out += Data[i]; 9 | } 10 | return Out; 11 | } 12 | 13 | 14 | class TextSystem{ 15 | public: 16 | bool Trigger = false; 17 | bool ReadLine = true; 18 | int LinePosition = 0; 19 | int FrameCounter = 0; 20 | 21 | string Lines = ""; 22 | string CurrentLine = ""; 23 | string SecondLine = ""; 24 | bool SEnable = false; 25 | Texture2D Bar; 26 | Font BarFont; 27 | Sound TextNoise; 28 | 29 | int ScaleValue = 0; 30 | Color TextColor = WHITE; 31 | 32 | int Red = 0; 33 | int Green = 0; 34 | int Blue = 0; 35 | 36 | Color TextBarColor = (Color){Red, Green, Blue, 255}; 37 | 38 | void Update(){ 39 | ScaleValue = int(GetScreenWidth() / 1280); 40 | TextBarColor = {Red, Green, Blue, Red}; 41 | 42 | if (Red != 0){ 43 | DrawTextureEx(Bar , { 0, 720 / 2 - 100} , 0 , 2 * ScaleValue, TextBarColor); 44 | } 45 | 46 | if (Trigger){ 47 | if (Red != 255){ 48 | Red ++; 49 | Green ++; 50 | Blue ++; 51 | } 52 | if (ReadLine){ 53 | for (int i = LinePosition ; i <= Lines.size(); i ++){ 54 | if (Lines[i] != '|'){ 55 | if (CurrentLine.size() != 51){ 56 | CurrentLine += Lines[i]; 57 | } 58 | else { 59 | SEnable = true; 60 | } 61 | 62 | if (SEnable){ 63 | SecondLine += Lines[i]; 64 | } 65 | 66 | LinePosition ++; 67 | } 68 | else { 69 | ReadLine = false; 70 | break; 71 | } 72 | if (Lines[i] == '*'){ 73 | exit(0); 74 | } 75 | if (Lines[i] == ' '){ 76 | StopSound(TextNoise); 77 | } 78 | if (Lines[i] == '/'){ 79 | CurrentLine = ""; 80 | LinePosition = 0; 81 | ReadLine = false; 82 | Trigger = false; 83 | break; 84 | } 85 | } 86 | } 87 | else { 88 | DrawTextEx(BarFont, TextSubtext(TextFormat("%s" , CurrentLine.c_str() ), 0 , FrameCounter / 3 ) , { 190* ScaleValue, 720 / 2 - 100 + 80 } , 30 , 1, TextColor); 89 | 90 | if (SEnable){ 91 | DrawTextEx(BarFont, TextSubtext(TextFormat("%s" , SecondLine.c_str() ), 0 , FrameCounter / 3) , { 190 * ScaleValue, 720 / 2 - 100 + 80 + 35 } , 30 , 1, TextColor); 92 | } 93 | if (FrameCounter != (CurrentLine.size() * 3) + SecondLine.size() * 3){ 94 | FrameCounter ++; 95 | } 96 | 97 | if (FrameCounter % 14 == 1){ 98 | StopSound(TextNoise); 99 | PlaySound(TextNoise); 100 | } 101 | 102 | if (OmegaInputController.TextButton){ 103 | Red = 255; 104 | Green = 255; 105 | Blue = 255; 106 | ReadLine = true; 107 | LinePosition+=1; 108 | CurrentLine = ""; 109 | SEnable = false; 110 | SecondLine = ""; 111 | FrameCounter = 0; 112 | } 113 | } 114 | } 115 | else { 116 | if (Red != 0){ 117 | Red -=5; 118 | Green -=5; 119 | Blue -=5; 120 | } 121 | } 122 | } 123 | 124 | auto Write(string SayLines){ 125 | Red = 0; 126 | Blue = 0; 127 | Green = 0; 128 | 129 | Lines = SayLines; 130 | CurrentLine = ""; 131 | SecondLine = ""; 132 | LinePosition = 0; 133 | ReadLine = true; 134 | Trigger = true; 135 | SEnable = false; 136 | } 137 | }; 138 | 139 | static TextSystem OmegaTechTextSystem; -------------------------------------------------------------------------------- /Source/Video.hpp: -------------------------------------------------------------------------------- 1 | #include "raylib.h" 2 | #include 3 | #include 4 | 5 | typedef struct ray_video_t { 6 | //doun't touch this! 7 | struct ray_video_thread_context_t * ctx; 8 | double time_in_s_till_next_frame; 9 | double frame_time_s; 10 | int video_state; 11 | 12 | //info data 13 | double worker_time; 14 | double update_time; 15 | double upload_time; 16 | double fps; 17 | int width; 18 | int height; 19 | int mipmaps; 20 | bool ok; 21 | 22 | Texture texture; 23 | } ray_video_t; 24 | 25 | // Keep in mind that ray_video keeps the file handle life and 26 | // will close it on it's own when ray_video_destroy is called. 27 | ray_video_t ray_video_open(const char * path); 28 | ray_video_t ray_video_open_file_handle(FILE * file); 29 | int ray_video_update(ray_video_t *, double deltatime_s); 30 | void ray_video_destroy(ray_video_t *); 31 | 32 | 33 | 34 | // WINAPI 35 | #include 36 | 37 | // Multithreading 38 | 39 | #include 40 | #ifndef _WIN32 41 | #include 42 | #endif 43 | 44 | typedef void* thread_ptr_t; 45 | typedef union thread_atomic_int64_t 46 | { 47 | void* align; 48 | int64_t i; 49 | } thread_atomic_int64_t; 50 | 51 | static inline int64_t atomic_cmpxchg( thread_atomic_int64_t* atomic, int64_t expected, int64_t desired ) { 52 | #if defined( _WIN32 ) 53 | return _InterlockedCompareExchange64( &atomic->i, desired, expected ); 54 | #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) 55 | return __sync_val_compare_and_swap( &atomic->i, expected, desired ); 56 | #else 57 | #error Unknown platform. 58 | #endif 59 | } 60 | 61 | static inline bool atomic_cmpxchg_expect( thread_atomic_int64_t* atomic, int64_t expected, int64_t desired ) { 62 | return expected == atomic_cmpxchg(atomic, expected, desired); 63 | } 64 | 65 | static inline int64_t atomic_get( thread_atomic_int64_t* atomic ) { 66 | return atomic_cmpxchg(atomic, 0, 0); 67 | } 68 | 69 | static inline void atomic_set( thread_atomic_int64_t* atomic, int64_t desired ) { 70 | #if defined( _WIN32 ) 71 | _InterlockedExchange64( &atomic->i, desired ); 72 | #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) 73 | __sync_fetch_and_and( &atomic->i, 0 ); 74 | __sync_fetch_and_or( &atomic->i, desired ); 75 | #else 76 | #error Unknown platform. 77 | #endif 78 | } 79 | 80 | static inline int64_t atomic_spin_till_expected( thread_atomic_int64_t* atomic, int64_t expected ) { 81 | int64_t spins = 0; 82 | while(atomic_get(atomic) != expected) { 83 | spins++; 84 | } 85 | return spins; 86 | } 87 | 88 | static inline thread_ptr_t thread_create( int (*thread_proc)( void* ), void* user_data, size_t stack_size ) { 89 | #if defined( _WIN32 ) 90 | { 91 | DWORD thread_id; 92 | HANDLE handle = CreateThread( 93 | NULL, stack_size, 94 | (LPTHREAD_START_ROUTINE)(uintptr_t) thread_proc, 95 | user_data, 0, &thread_id 96 | ); 97 | (void)(thread_id); 98 | if( !handle ) return NULL; 99 | return (thread_ptr_t) handle; 100 | } 101 | #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) 102 | { 103 | pthread_t thread; 104 | if( 0 != pthread_create( &thread, NULL, ( void* (*)( void * ) ) thread_proc, user_data ) ) 105 | return NULL; 106 | 107 | return (thread_ptr_t) thread; 108 | } 109 | #else 110 | #error Unknown platform. 111 | #endif 112 | } 113 | 114 | // mini perf 115 | 116 | #include 117 | 118 | typedef struct performance_counter_t { 119 | double ticktime_seconds; // time scaler of the performance counter 120 | double ticktime_miliseconds; // time scaler of the performance counter 121 | double ticktime_nanoseconds; // time scaler of the performance counter 122 | int64_t start_time; // starting time 123 | int64_t end_time; // ending time 124 | } performance_counter_t; 125 | 126 | inline void performance_counter_init(performance_counter_t * c) { 127 | memset(c, 0, sizeof(performance_counter_t)); 128 | #ifdef _WIN32 129 | // get the frequency of the performance counter 130 | LARGE_INTEGER frequency; 131 | QueryPerformanceFrequency(&frequency); 132 | c->ticktime_seconds = 1.0 / frequency.QuadPart; 133 | c->ticktime_miliseconds = 1000.0 / frequency.QuadPart; 134 | c->ticktime_nanoseconds = 1000000.0 / frequency.QuadPart; 135 | 136 | // get the starting time 137 | LARGE_INTEGER LL; 138 | QueryPerformanceCounter(&LL); 139 | c->start_time = LL.QuadPart; 140 | c->end_time = c->start_time; 141 | #endif 142 | } 143 | 144 | inline void performance_counter_next(performance_counter_t * c) { 145 | // get the ending time 146 | #ifdef _WIN32 147 | LARGE_INTEGER LL; 148 | QueryPerformanceCounter(&LL); 149 | c->end_time = LL.QuadPart; 150 | #endif 151 | } 152 | 153 | inline double performance_counter_next_seconds(performance_counter_t * c) { 154 | performance_counter_next(c); 155 | return (c->end_time - c->start_time) * c->ticktime_seconds; 156 | } 157 | 158 | inline double performance_counter_next_miliseconds(performance_counter_t * c) { 159 | performance_counter_next(c); 160 | return (c->end_time - c->start_time) * c->ticktime_miliseconds; 161 | } 162 | 163 | inline double performance_counter_next_nanoseconds(performance_counter_t * c) { 164 | performance_counter_next(c); 165 | return (c->end_time - c->start_time) * c->ticktime_nanoseconds; 166 | } 167 | 168 | inline void performance_counter_reset(performance_counter_t * c) { 169 | performance_counter_next(c); 170 | c->start_time = c->end_time; 171 | } 172 | 173 | // implementation 174 | 175 | #define PL_MPEG_IMPLEMENTATION 176 | #include "plmpeg/pl_mpeg.h" 177 | #include 178 | #include 179 | 180 | #define THREAD_STATE_IDLE 0 181 | #define THREAD_STATE_WORK 1 182 | 183 | enum ray_video_update_status { 184 | RAY_VIDEO_UPDATE_STATUS_NO_UPDATE = 0, 185 | RAY_VIDEO_UPDATE_STATUS_NEW_FRAME, 186 | RAY_VIDEO_UPDATE_STATUS_DONE, 187 | RAY_VIDEO_UPDATE_STATUS_ERROR 188 | }; 189 | 190 | enum ray_video_state { 191 | RAY_VIDEO_STATE_FIRST_FRAME = 0, 192 | RAY_VIDEO_STATE_BUSY, 193 | RAY_VIDEO_STATE_READY, 194 | RAY_VIDEO_STATE_DONE 195 | }; 196 | 197 | typedef struct ray_video_thread_context_t { 198 | thread_atomic_int64_t thread_state; 199 | plm_t * plm; 200 | uint8_t * rgb_buffer; 201 | 202 | double thread_worker_time; 203 | int video_state; 204 | int stride; 205 | } ray_video_thread_context_t; 206 | 207 | static int ray_video_thread_state(ray_video_thread_context_t * ctx) { 208 | if(atomic_get(&ctx->thread_state) == THREAD_STATE_WORK) return RAY_VIDEO_STATE_BUSY; 209 | return ctx->video_state; 210 | } 211 | 212 | static int ray_video_thread_worker(void * user) { 213 | ray_video_thread_context_t * ctx = (ray_video_thread_context_t *)(user); 214 | 215 | performance_counter_t perf; 216 | performance_counter_init(&perf); 217 | 218 | int video_state; 219 | plm_frame_t * frame = plm_decode_video(ctx->plm); 220 | 221 | if(!frame) { 222 | //TODO: configure video to automatically replay in a loop. 223 | video_state = RAY_VIDEO_STATE_DONE; 224 | } 225 | else { 226 | plm_frame_to_rgb(frame, ctx->rgb_buffer, ctx->stride); 227 | video_state = RAY_VIDEO_STATE_READY; 228 | } 229 | 230 | ctx->thread_worker_time = performance_counter_next_seconds(&perf); 231 | ctx->video_state = video_state; 232 | bool ok = atomic_cmpxchg_expect(&ctx->thread_state, THREAD_STATE_WORK, THREAD_STATE_IDLE); 233 | return ok ? 0 : 1; 234 | } 235 | 236 | static void start_new_fetch_worker(ray_video_thread_context_t * ctx) { 237 | atomic_set(&ctx->thread_state, THREAD_STATE_WORK); 238 | thread_create(ray_video_thread_worker, ctx, 0); 239 | } 240 | 241 | static int update_video(ray_video_t * video, double deltatime_s) { 242 | switch(video->video_state) { 243 | break; case RAY_VIDEO_STATE_FIRST_FRAME: 244 | video->time_in_s_till_next_frame = video->frame_time_s; 245 | video->video_state = RAY_VIDEO_STATE_READY; 246 | break; case RAY_VIDEO_STATE_READY: 247 | video->time_in_s_till_next_frame -= deltatime_s; 248 | if(video->time_in_s_till_next_frame > 0.0) { 249 | return RAY_VIDEO_UPDATE_STATUS_NO_UPDATE; 250 | } 251 | else { 252 | video->time_in_s_till_next_frame += video->frame_time_s; 253 | if(video->time_in_s_till_next_frame < 0) { 254 | //video->time_in_s_till_next_frame = 0; 255 | } 256 | } 257 | break; case RAY_VIDEO_STATE_DONE: 258 | return RAY_VIDEO_UPDATE_STATUS_DONE; 259 | break; case RAY_VIDEO_STATE_BUSY: 260 | //Don't change the delta time before we get the next frame. 261 | break; 262 | } 263 | 264 | video->video_state = ray_video_thread_state(video->ctx); 265 | if(video->video_state == RAY_VIDEO_STATE_BUSY) { 266 | //Thread is still busy. Skip this frame and hope we get it next time. 267 | //TODO: add option to wait for frame. 268 | return RAY_VIDEO_UPDATE_STATUS_NO_UPDATE; 269 | } 270 | 271 | if(video->video_state == RAY_VIDEO_STATE_READY) { 272 | return RAY_VIDEO_UPDATE_STATUS_NEW_FRAME; 273 | } 274 | return RAY_VIDEO_UPDATE_STATUS_DONE; 275 | } 276 | 277 | ray_video_t ray_video_create_by_file_handle(FILE * file) { 278 | ray_video_t video; 279 | memset(&video, 0, sizeof(ray_video_t)); 280 | video.ok = false; 281 | 282 | if(file) { 283 | plm_t * plm = plm_create_with_file(file, 0); 284 | if(!plm) return video; 285 | 286 | plm_set_audio_enabled(plm, 0); 287 | video.mipmaps = 1; //Does video even need mipmaps? UpdateTexture ignores the mipmaps anyway. 288 | video.width = plm_get_width(plm); 289 | video.height = plm_get_height(plm); 290 | video.fps = plm_get_framerate(plm); 291 | video.frame_time_s = 1.0 / video.fps; 292 | 293 | video.ctx = (ray_video_thread_context_t *)calloc(1, sizeof(ray_video_thread_context_t)); 294 | video.ctx->plm = plm; 295 | video.ctx->rgb_buffer = (uint8_t *)malloc(3 * video.width * video.height); 296 | video.ctx->stride = 3 * video.width; 297 | start_new_fetch_worker(video.ctx); 298 | video.ok = true; 299 | } 300 | 301 | return video; 302 | } 303 | 304 | ray_video_t ray_video_open(const char * path) { 305 | return ray_video_create_by_file_handle(fopen(path, "rb")); 306 | } 307 | 308 | int ray_video_update(ray_video_t * video, double deltatime_s) { 309 | int state; 310 | performance_counter_t perf; 311 | 312 | if(!video->ok) return RAY_VIDEO_UPDATE_STATUS_ERROR; 313 | 314 | performance_counter_init(&perf); 315 | state = update_video(video, deltatime_s); 316 | video->update_time = performance_counter_next_seconds(&perf); 317 | if(state == RAY_VIDEO_UPDATE_STATUS_NEW_FRAME) { 318 | performance_counter_reset(&perf); 319 | if(video->texture.id == 0) { 320 | int format = RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8; 321 | 322 | video->texture.id = rlLoadTexture(video->ctx->rgb_buffer, video->width, video->height, format, video->mipmaps); 323 | video->texture.width = video->width; 324 | video->texture.height = video->height; 325 | video->texture.mipmaps = video->mipmaps; 326 | video->texture.format = format; 327 | } 328 | else { 329 | UpdateTexture(video->texture, video->ctx->rgb_buffer); 330 | } 331 | video->worker_time = video->ctx->thread_worker_time; 332 | video->upload_time = performance_counter_next_seconds(&perf); 333 | 334 | start_new_fetch_worker(video->ctx); 335 | } 336 | return state; 337 | } 338 | 339 | void ray_video_destroy(ray_video_t * video) { 340 | if(!video) return; 341 | 342 | if(video->ctx) { 343 | atomic_spin_till_expected(&video->ctx->thread_state, THREAD_STATE_IDLE); 344 | 345 | if(video->ctx->plm) plm_destroy(video->ctx->plm); 346 | if(video->ctx->rgb_buffer) free(video->ctx->rgb_buffer); 347 | free(video->ctx); 348 | } 349 | memset(video, 0, sizeof(ray_video_t)); 350 | } -------------------------------------------------------------------------------- /Source/raygui/dark.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // StyleAsCode exporter v1.2 - Style data exported as a values array // 4 | // // 5 | // USAGE: On init call: GuiLoadStyleDark(); // 6 | // // 7 | // more info and bugs-report: github.com/raysan5/raygui // 8 | // feedback and support: ray[at]raylibtech.com // 9 | // // 10 | // Copyright (c) 2020-2023 raylib technologies (@raylibtech) // 11 | // // 12 | ////////////////////////////////////////////////////////////////////////////////// 13 | #include 14 | #include 15 | 16 | #define DARK_STYLE_PROPS_COUNT 22 17 | 18 | // Custom style name: dark 19 | static const GuiStyleProp darkStyleProps[DARK_STYLE_PROPS_COUNT] = { 20 | { 0, 0, 0x880808ff }, // DEFAULT_BORDER_COLOR_NORMAL 21 | { 0, 1, 0x9A2A2Aff }, // DEFAULT_BASE_COLOR_NORMAL 22 | { 0, 2, 0xc3c3c3ff }, // DEFAULT_TEXT_COLOR_NORMAL 23 | { 0, 3, 0xe1e1e1ff }, // DEFAULT_BORDER_COLOR_FOCUSED 24 | { 0, 4, 0x848484ff }, // DEFAULT_BASE_COLOR_FOCUSED 25 | { 0, 5, 0x181818ff }, // DEFAULT_TEXT_COLOR_FOCUSED 26 | { 0, 6, 0x000000ff }, // DEFAULT_BORDER_COLOR_PRESSED 27 | { 0, 7, 0xefefefff }, // DEFAULT_BASE_COLOR_PRESSED 28 | { 0, 8, 0x202020ff }, // DEFAULT_TEXT_COLOR_PRESSED 29 | { 0, 9, 0x6a6a6aff }, // DEFAULT_BORDER_COLOR_DISABLED 30 | { 0, 10, 0x818181ff }, // DEFAULT_BASE_COLOR_DISABLED 31 | { 0, 11, 0x606060ff }, // DEFAULT_TEXT_COLOR_DISABLED 32 | { 0, 16, 0x00000010 }, // DEFAULT_TEXT_SIZE 33 | { 0, 17, 0x00000000 }, // DEFAULT_TEXT_SPACING 34 | { 0, 18, 0x9d9d9dff }, // DEFAULT_LINE_COLOR 35 | { 0, 19, 0x3c3c3cff }, // DEFAULT_BACKGROUND_COLOR 36 | { 1, 5, 0xf7f7f7ff }, // LABEL_TEXT_COLOR_FOCUSED 37 | { 1, 8, 0x898989ff }, // LABEL_TEXT_COLOR_PRESSED 38 | { 4, 5, 0xb0b0b0ff }, // SLIDER_TEXT_COLOR_FOCUSED 39 | { 5, 5, 0x848484ff }, // PROGRESSBAR_TEXT_COLOR_FOCUSED 40 | { 9, 5, 0xf5f5f5ff }, // TEXTBOX_TEXT_COLOR_FOCUSED 41 | { 10, 5, 0xf6f6f6ff }, // VALUEBOX_TEXT_COLOR_FOCUSED 42 | }; 43 | 44 | // WARNING: This style uses a custom font: PixelOperator.ttf (size: 16, spacing: 0) 45 | 46 | #define DARK_COMPRESSED_DATA_SIZE 1031 47 | 48 | // Font image pixels data compressed (DEFLATE) 49 | // NOTE: Original pixel data simplified to GRAYSCALE 50 | static unsigned char darkFontData[DARK_COMPRESSED_DATA_SIZE] = { 0xed, 51 | 0xdd, 0xd1, 0x76, 0x9b, 0x30, 0x0c, 0x00, 0x50, 0xff, 0xff, 0x4f, 0x6b, 0x4f, 0x3b, 0xeb, 0xb6, 0x16, 0x90, 0x90, 0x8d, 52 | 0x93, 0xdc, 0xdd, 0x97, 0x9d, 0x36, 0x25, 0xc4, 0xc2, 0xc6, 0x04, 0xc9, 0xc4, 0x00, 0x00, 0xf8, 0x47, 0x7c, 0xfb, 0x93, 53 | 0xf8, 0xf1, 0x95, 0x71, 0x79, 0x3b, 0xc7, 0x3f, 0xff, 0xfd, 0xdb, 0x38, 0x78, 0xaf, 0x6b, 0xfb, 0x9a, 0x7d, 0xdf, 0x48, 54 | 0xb4, 0xc4, 0xf7, 0xfb, 0x17, 0x97, 0xb7, 0xfb, 0xd3, 0xe7, 0xcb, 0xbf, 0xfe, 0x68, 0x4b, 0xe7, 0xed, 0xfc, 0x54, 0xfc, 55 | 0xe3, 0x52, 0x24, 0xe2, 0x62, 0xdb, 0x5c, 0x6f, 0xc5, 0xa3, 0x77, 0x8e, 0xe6, 0x16, 0x3c, 0x3f, 0x3a, 0x7f, 0x8a, 0x74, 56 | 0xbe, 0x3d, 0xe2, 0xa0, 0x1f, 0xcd, 0x8d, 0xff, 0xd7, 0x7f, 0xb9, 0x7e, 0x1c, 0xc9, 0x88, 0x76, 0xf4, 0xf4, 0xe3, 0xfd, 57 | 0x8c, 0xd4, 0xf6, 0x67, 0xc4, 0x3f, 0x5a, 0xc7, 0xae, 0x68, 0xed, 0xff, 0xc7, 0xaf, 0xcc, 0xf6, 0xb7, 0x48, 0xf6, 0xdd, 58 | 0x8e, 0x36, 0xa9, 0xf5, 0xff, 0xee, 0xe8, 0xff, 0xf9, 0xec, 0x7d, 0xe3, 0x50, 0x7e, 0x5c, 0x5e, 0x19, 0xff, 0x4a, 0xec, 59 | 0xae, 0x8e, 0x5c, 0x95, 0x3e, 0x31, 0x36, 0x88, 0x7f, 0xf6, 0x38, 0x3c, 0x6e, 0xab, 0x91, 0x3e, 0x33, 0x3c, 0x1f, 0xff, 60 | 0xf3, 0xf1, 0x3f, 0x26, 0xc4, 0xff, 0xf9, 0x79, 0xf4, 0x9f, 0x88, 0x45, 0xb2, 0x2f, 0xe7, 0xce, 0x31, 0x91, 0xe8, 0x45, 61 | 0xf5, 0xd6, 0xab, 0x9d, 0xff, 0xbf, 0x46, 0x3f, 0xde, 0x38, 0xfe, 0x91, 0x9c, 0xdf, 0x66, 0xe7, 0x38, 0x3b, 0xb4, 0xc2, 62 | 0xf9, 0xfc, 0xff, 0x78, 0xef, 0xe2, 0xe6, 0xd8, 0x15, 0x2f, 0xd6, 0xfb, 0x3b, 0xe3, 0x1f, 0xd3, 0xe2, 0x1f, 0x4b, 0xe2, 63 | 0x3f, 0x0e, 0xaf, 0x6a, 0xe3, 0xf6, 0x0c, 0x7b, 0xcf, 0xf8, 0x67, 0xaf, 0xff, 0x6b, 0x23, 0xec, 0xf3, 0x2d, 0x11, 0x37, 64 | 0xaf, 0x41, 0x78, 0xfd, 0x6f, 0x11, 0x43, 0xf4, 0x7d, 0x8f, 0x8c, 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8b, 0xef, 65 | 0xd0, 0x45, 0x53, 0xb6, 0x6c, 0x25, 0x53, 0xfd, 0x5e, 0x9e, 0x7f, 0x2e, 0x6b, 0xf7, 0x6c, 0xef, 0xf2, 0xfb, 0xde, 0xf9, 66 | 0x37, 0x47, 0x59, 0xc8, 0xb5, 0x1c, 0xeb, 0x2b, 0x95, 0x16, 0x9d, 0xb9, 0x25, 0xf5, 0x4c, 0xf5, 0xee, 0x3b, 0x49, 0x51, 67 | 0xae, 0x2b, 0xe8, 0xf9, 0x54, 0x77, 0x7e, 0xd3, 0x13, 0xa5, 0xae, 0xf8, 0x8f, 0x2d, 0xe2, 0x9f, 0xcf, 0x13, 0xca, 0x1f, 68 | 0xb7, 0x91, 0xce, 0x47, 0x8b, 0xd6, 0x9c, 0xad, 0x68, 0x8d, 0x52, 0x24, 0x2a, 0xad, 0x7a, 0x72, 0x4e, 0x77, 0xef, 0xff, 69 | 0xd7, 0x32, 0xb2, 0x3f, 0x2b, 0xfe, 0xf9, 0x73, 0xeb, 0xdd, 0x33, 0xec, 0x8a, 0x5c, 0x82, 0x6a, 0xa5, 0x4c, 0x3e, 0xfe, 70 | 0xf9, 0xde, 0x73, 0xb6, 0xb5, 0x51, 0xca, 0xa3, 0xbe, 0x9b, 0x01, 0x9e, 0xad, 0x52, 0x5b, 0x9d, 0x8f, 0x3a, 0x3f, 0x23, 71 | 0x37, 0x2e, 0xd4, 0xb8, 0xed, 0xdb, 0xff, 0x63, 0x42, 0xff, 0x5f, 0x93, 0x8f, 0x1c, 0x4b, 0x8f, 0x92, 0xb3, 0x5e, 0xd4, 72 | 0x75, 0x56, 0x7b, 0x95, 0xf8, 0xaf, 0xfe, 0x6c, 0xb1, 0x65, 0xd6, 0xd8, 0xbc, 0x36, 0xda, 0x7d, 0xfe, 0xdf, 0x75, 0xc5, 73 | 0x7e, 0xbf, 0x52, 0x7d, 0x4d, 0xf4, 0xa3, 0xf4, 0x3d, 0x48, 0x65, 0x8e, 0xd4, 0x7b, 0xfd, 0x9f, 0x9f, 0xc1, 0x87, 0x0c, 74 | 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x8f, 0xca, 0xff, 0x5f, 0x93, 0x11, 0x34, 0x4a, 0x2b, 0xa1, 0xcf, 0xcf, 75 | 0xb9, 0xbf, 0xb3, 0x26, 0x78, 0x3c, 0x9c, 0x61, 0x7e, 0x5c, 0x2d, 0xf0, 0xda, 0xf1, 0x7f, 0xfe, 0x37, 0xa3, 0xb0, 0x7e, 76 | 0xe7, 0xca, 0xf8, 0x8f, 0x42, 0x34, 0x7a, 0xb2, 0xe4, 0x73, 0x5b, 0x89, 0xff, 0xfe, 0xb7, 0x63, 0xfc, 0xc7, 0x92, 0xf8, 77 | 0xc7, 0xcb, 0xc7, 0xbf, 0x52, 0x6b, 0x71, 0x9c, 0x59, 0x2b, 0xfe, 0xe7, 0x6d, 0x1b, 0xa5, 0x2a, 0x8c, 0xfe, 0xf8, 0x47, 78 | 0x71, 0x2b, 0x71, 0x72, 0x44, 0xf5, 0xe6, 0xdc, 0xf7, 0xe4, 0xe9, 0xad, 0x8d, 0x7f, 0xf7, 0x73, 0x3f, 0x76, 0xea, 0xff, 79 | 0xd7, 0xea, 0xae, 0x66, 0x67, 0x1f, 0xdf, 0xe9, 0xe9, 0x4f, 0xf6, 0xff, 0xee, 0x67, 0x6b, 0xad, 0x3e, 0xff, 0xcf, 0x9a, 80 | 0xff, 0x8d, 0xf4, 0x68, 0x12, 0xdb, 0xc6, 0xff, 0xce, 0x2c, 0xb4, 0x3b, 0xfe, 0xf1, 0x22, 0xf3, 0xff, 0x51, 0x38, 0x3e, 81 | 0x67, 0xcf, 0xff, 0xaf, 0x3d, 0xef, 0x68, 0xef, 0xf8, 0x8f, 0x1b, 0xe7, 0xd7, 0x58, 0x72, 0xfd, 0x3f, 0x4e, 0xae, 0x36, 82 | 0x7a, 0xde, 0x67, 0xb4, 0xad, 0xdf, 0xff, 0xf7, 0xbe, 0xe5, 0x6b, 0xf5, 0xb3, 0x2b, 0x16, 0x58, 0x75, 0x1d, 0x00, 0x00, 83 | 0x00, 0x00, 0x00, 0x00, 0x40, 0xfe, 0xff, 0xd9, 0x1d, 0xe4, 0xfc, 0xbd, 0xe8, 0xd1, 0x78, 0x6f, 0x3f, 0x9a, 0x32, 0x19, 84 | 0xc6, 0xc1, 0x9d, 0xf8, 0xec, 0x0a, 0x7c, 0x3d, 0x99, 0xb9, 0x47, 0x7b, 0xdf, 0x57, 0xd3, 0x30, 0x6e, 0xef, 0x51, 0x7e, 85 | 0x3d, 0xc1, 0xe7, 0x57, 0x96, 0x8d, 0xc6, 0xcc, 0xae, 0x75, 0xd5, 0x36, 0x33, 0x73, 0xc6, 0xbb, 0xeb, 0x3f, 0xba, 0x5a, 86 | 0x23, 0x6e, 0x8c, 0x0c, 0xb3, 0xe3, 0x5f, 0x5f, 0xe9, 0xbb, 0x7a, 0x7c, 0xad, 0x88, 0x7f, 0x4f, 0x16, 0x69, 0x3e, 0xf2, 87 | 0x6b, 0xd6, 0xd3, 0x3e, 0x7b, 0x9e, 0xca, 0xba, 0xdc, 0xc7, 0x4a, 0x06, 0xed, 0xbb, 0xc6, 0xff, 0xf9, 0xf5, 0xb4, 0x67, 88 | 0x55, 0x76, 0xf5, 0x66, 0xd0, 0x8b, 0xff, 0xbc, 0xda, 0xbe, 0x58, 0x38, 0x32, 0x55, 0x2b, 0x68, 0xe6, 0xd5, 0x0c, 0x76, 89 | 0x57, 0x91, 0xcc, 0x1f, 0xff, 0x6b, 0xcf, 0xb9, 0xaa, 0x3c, 0x1d, 0x68, 0xb7, 0xfe, 0xdf, 0x99, 0x3b, 0xbd, 0x4b, 0xfc, 90 | 0xeb, 0xb3, 0xfc, 0xd1, 0x34, 0x2b, 0x7d, 0x6e, 0xfc, 0x5f, 0xfd, 0xc4, 0x8b, 0xfa, 0x3c, 0xfc, 0x89, 0x3d, 0xa9, 0xbc, 91 | 0x73, 0xe5, 0xaf, 0xb2, 0x99, 0xfd, 0x9d, 0xf1, 0xdf, 0xef, 0x08, 0xe0, 0xe9, 0x51, 0x8c, 0xf7, 0x3a, 0x02, 0x54, 0xe0, 92 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x36, 0xbb, 0xe3, 0x7e, 0x9c, 0xa5, 0x13, 0x2d, 0x19, 0x37, 0xbb, 0xaf, 0xa5, 93 | 0x3f, 0x4e, 0xd6, 0xa7, 0xbd, 0x96, 0xdb, 0x15, 0xdb, 0xde, 0x0f, 0xae, 0xb6, 0x7f, 0x57, 0xfe, 0xf4, 0xee, 0x6b, 0xe9, 94 | 0xdf, 0x5f, 0x93, 0x33, 0x4e, 0x8e, 0x8e, 0x57, 0x8c, 0x7f, 0x25, 0x67, 0xf4, 0xf9, 0xb5, 0x94, 0xa3, 0x94, 0xf1, 0x1a, 95 | 0x9b, 0xe7, 0xcc, 0xed, 0x94, 0x8b, 0xbd, 0x72, 0xfc, 0x8f, 0x72, 0x74, 0xa2, 0x21, 0x0f, 0x5a, 0xfc, 0x47, 0xba, 0x16, 96 | 0x6f, 0xe7, 0xfe, 0xff, 0xc4, 0xda, 0xeb, 0xef, 0x17, 0xff, 0xce, 0x8a, 0xab, 0x19, 0x6b, 0x69, 0xe7, 0xab, 0x3b, 0xdf, 97 | 0xbf, 0xff, 0x57, 0xe7, 0xff, 0x3d, 0xe3, 0xff, 0xea, 0xb5, 0xb4, 0xf3, 0xf3, 0xff, 0xcf, 0x18, 0xff, 0xef, 0xbc, 0x22, 98 | 0x73, 0xac, 0xbd, 0x5e, 0x5e, 0xae, 0xf8, 0x7f, 0x7a, 0x5e, 0xee, 0xdd, 0xeb, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 99 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 100 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 101 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 102 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x46, 0xbf, 0x00 }; 103 | 104 | // Font characters rectangles data 105 | static const Rectangle darkFontRecs[95] = { 106 | { 4, 4, 4 , 16 }, 107 | { 16, 4, 1 , 9 }, 108 | { 25, 4, 3 , 3 }, 109 | { 36, 4, 6 , 9 }, 110 | { 50, 4, 5 , 13 }, 111 | { 63, 4, 7 , 9 }, 112 | { 78, 4, 5 , 9 }, 113 | { 91, 4, 1 , 3 }, 114 | { 100, 4, 3 , 9 }, 115 | { 111, 4, 3 , 9 }, 116 | { 122, 4, 5 , 5 }, 117 | { 135, 4, 5 , 5 }, 118 | { 148, 4, 2 , 3 }, 119 | { 158, 4, 4 , 1 }, 120 | { 170, 4, 1 , 1 }, 121 | { 179, 4, 3 , 9 }, 122 | { 190, 4, 5 , 9 }, 123 | { 203, 4, 3 , 9 }, 124 | { 214, 4, 5 , 9 }, 125 | { 227, 4, 5 , 9 }, 126 | { 240, 4, 5 , 9 }, 127 | { 4, 28, 5 , 9 }, 128 | { 17, 28, 5 , 9 }, 129 | { 30, 28, 5 , 9 }, 130 | { 43, 28, 5 , 9 }, 131 | { 56, 28, 5 , 9 }, 132 | { 69, 28, 1 , 7 }, 133 | { 78, 28, 2 , 9 }, 134 | { 88, 28, 3 , 5 }, 135 | { 99, 28, 4 , 3 }, 136 | { 111, 28, 3 , 5 }, 137 | { 122, 28, 5 , 9 }, 138 | { 135, 28, 7 , 9 }, 139 | { 150, 28, 5 , 9 }, 140 | { 163, 28, 5 , 9 }, 141 | { 176, 28, 5 , 9 }, 142 | { 189, 28, 5 , 9 }, 143 | { 202, 28, 5 , 9 }, 144 | { 215, 28, 5 , 9 }, 145 | { 228, 28, 5 , 9 }, 146 | { 241, 28, 5 , 9 }, 147 | { 4, 52, 1 , 9 }, 148 | { 13, 52, 5 , 9 }, 149 | { 26, 52, 5 , 9 }, 150 | { 39, 52, 5 , 9 }, 151 | { 52, 52, 7 , 9 }, 152 | { 67, 52, 5 , 9 }, 153 | { 80, 52, 5 , 9 }, 154 | { 93, 52, 5 , 9 }, 155 | { 106, 52, 5 , 9 }, 156 | { 119, 52, 5 , 9 }, 157 | { 132, 52, 5 , 9 }, 158 | { 145, 52, 5 , 9 }, 159 | { 158, 52, 5 , 9 }, 160 | { 171, 52, 5 , 9 }, 161 | { 184, 52, 7 , 9 }, 162 | { 199, 52, 5 , 9 }, 163 | { 212, 52, 5 , 9 }, 164 | { 225, 52, 5 , 9 }, 165 | { 238, 52, 3 , 9 }, 166 | { 4, 76, 3 , 9 }, 167 | { 15, 76, 3 , 9 }, 168 | { 26, 76, 5 , 3 }, 169 | { 39, 76, 5 , 1 }, 170 | { 52, 76, 2 , 2 }, 171 | { 62, 76, 5 , 7 }, 172 | { 75, 76, 5 , 9 }, 173 | { 88, 76, 5 , 7 }, 174 | { 101, 76, 5 , 9 }, 175 | { 114, 76, 5 , 7 }, 176 | { 127, 76, 4 , 9 }, 177 | { 139, 76, 5 , 9 }, 178 | { 152, 76, 5 , 9 }, 179 | { 165, 76, 1 , 9 }, 180 | { 174, 76, 5 , 11 }, 181 | { 187, 76, 5 , 9 }, 182 | { 200, 76, 2 , 9 }, 183 | { 210, 76, 7 , 7 }, 184 | { 225, 76, 5 , 7 }, 185 | { 238, 76, 5 , 7 }, 186 | { 4, 100, 5 , 9 }, 187 | { 17, 100, 5 , 9 }, 188 | { 30, 100, 5 , 7 }, 189 | { 43, 100, 5 , 7 }, 190 | { 56, 100, 4 , 8 }, 191 | { 68, 100, 5 , 7 }, 192 | { 81, 100, 5 , 7 }, 193 | { 94, 100, 7 , 7 }, 194 | { 109, 100, 5 , 7 }, 195 | { 122, 100, 5 , 9 }, 196 | { 135, 100, 5 , 7 }, 197 | { 148, 100, 4 , 9 }, 198 | { 160, 100, 1 , 9 }, 199 | { 169, 100, 4 , 9 }, 200 | { 181, 100, 6 , 2 }, 201 | }; 202 | 203 | // Font glyphs info data 204 | // NOTE: No glyphs.image data provided 205 | static const GlyphInfo darkFontChars[95] = { 206 | { 32, 0, 13, 4, { 0 }}, 207 | { 33, 2, 4, 5, { 0 }}, 208 | { 34, 2, 4, 7, { 0 }}, 209 | { 35, 1, 4, 8, { 0 }}, 210 | { 36, 1, 2, 7, { 0 }}, 211 | { 37, 1, 4, 9, { 0 }}, 212 | { 38, 1, 4, 7, { 0 }}, 213 | { 39, 2, 4, 5, { 0 }}, 214 | { 40, 3, 4, 7, { 0 }}, 215 | { 41, 1, 4, 7, { 0 }}, 216 | { 42, 1, 4, 7, { 0 }}, 217 | { 43, 1, 6, 7, { 0 }}, 218 | { 44, 1, 12, 5, { 0 }}, 219 | { 45, 1, 8, 6, { 0 }}, 220 | { 46, 2, 12, 5, { 0 }}, 221 | { 47, 1, 4, 5, { 0 }}, 222 | { 48, 1, 4, 7, { 0 }}, 223 | { 49, 2, 4, 7, { 0 }}, 224 | { 50, 1, 4, 7, { 0 }}, 225 | { 51, 1, 4, 7, { 0 }}, 226 | { 52, 1, 4, 7, { 0 }}, 227 | { 53, 1, 4, 7, { 0 }}, 228 | { 54, 1, 4, 7, { 0 }}, 229 | { 55, 1, 4, 7, { 0 }}, 230 | { 56, 1, 4, 7, { 0 }}, 231 | { 57, 1, 4, 7, { 0 }}, 232 | { 58, 2, 6, 5, { 0 }}, 233 | { 59, 1, 6, 5, { 0 }}, 234 | { 60, 1, 6, 5, { 0 }}, 235 | { 61, 1, 7, 6, { 0 }}, 236 | { 62, 1, 6, 5, { 0 }}, 237 | { 63, 1, 4, 7, { 0 }}, 238 | { 64, 1, 4, 9, { 0 }}, 239 | { 65, 1, 4, 7, { 0 }}, 240 | { 66, 1, 4, 7, { 0 }}, 241 | { 67, 1, 4, 7, { 0 }}, 242 | { 68, 1, 4, 7, { 0 }}, 243 | { 69, 1, 4, 7, { 0 }}, 244 | { 70, 1, 4, 7, { 0 }}, 245 | { 71, 1, 4, 7, { 0 }}, 246 | { 72, 1, 4, 7, { 0 }}, 247 | { 73, 2, 4, 5, { 0 }}, 248 | { 74, 1, 4, 7, { 0 }}, 249 | { 75, 1, 4, 7, { 0 }}, 250 | { 76, 1, 4, 7, { 0 }}, 251 | { 77, 1, 4, 9, { 0 }}, 252 | { 78, 1, 4, 7, { 0 }}, 253 | { 79, 1, 4, 7, { 0 }}, 254 | { 80, 1, 4, 7, { 0 }}, 255 | { 81, 1, 4, 7, { 0 }}, 256 | { 82, 1, 4, 7, { 0 }}, 257 | { 83, 1, 4, 7, { 0 }}, 258 | { 84, 1, 4, 7, { 0 }}, 259 | { 85, 1, 4, 7, { 0 }}, 260 | { 86, 1, 4, 7, { 0 }}, 261 | { 87, 1, 4, 9, { 0 }}, 262 | { 88, 1, 4, 7, { 0 }}, 263 | { 89, 1, 4, 7, { 0 }}, 264 | { 90, 1, 4, 7, { 0 }}, 265 | { 91, 3, 4, 7, { 0 }}, 266 | { 92, 1, 4, 5, { 0 }}, 267 | { 93, 1, 4, 7, { 0 }}, 268 | { 94, 1, 4, 7, { 0 }}, 269 | { 95, 0, 14, 5, { 0 }}, 270 | { 96, 1, 4, 5, { 0 }}, 271 | { 97, 1, 6, 7, { 0 }}, 272 | { 98, 1, 4, 7, { 0 }}, 273 | { 99, 1, 6, 7, { 0 }}, 274 | { 100, 1, 4, 7, { 0 }}, 275 | { 101, 1, 6, 7, { 0 }}, 276 | { 102, 1, 4, 6, { 0 }}, 277 | { 103, 1, 6, 7, { 0 }}, 278 | { 104, 1, 4, 7, { 0 }}, 279 | { 105, 2, 4, 5, { 0 }}, 280 | { 106, 1, 4, 7, { 0 }}, 281 | { 107, 1, 4, 7, { 0 }}, 282 | { 108, 2, 4, 5, { 0 }}, 283 | { 109, 1, 6, 9, { 0 }}, 284 | { 110, 1, 6, 7, { 0 }}, 285 | { 111, 1, 6, 7, { 0 }}, 286 | { 112, 1, 6, 7, { 0 }}, 287 | { 113, 1, 6, 7, { 0 }}, 288 | { 114, 1, 6, 7, { 0 }}, 289 | { 115, 1, 6, 7, { 0 }}, 290 | { 116, 1, 5, 6, { 0 }}, 291 | { 117, 1, 6, 7, { 0 }}, 292 | { 118, 1, 6, 7, { 0 }}, 293 | { 119, 1, 6, 9, { 0 }}, 294 | { 120, 1, 6, 7, { 0 }}, 295 | { 121, 1, 6, 7, { 0 }}, 296 | { 122, 1, 6, 7, { 0 }}, 297 | { 123, 2, 4, 7, { 0 }}, 298 | { 124, 2, 4, 5, { 0 }}, 299 | { 125, 1, 4, 7, { 0 }}, 300 | { 126, 1, 4, 8, { 0 }}, 301 | }; 302 | 303 | // Style loading function: dark 304 | static void GuiLoadStyleDark(void) 305 | { 306 | // Load style properties provided 307 | // NOTE: Default properties are propagated 308 | for (int i = 0; i < DARK_STYLE_PROPS_COUNT; i++) 309 | { 310 | GuiSetStyle(darkStyleProps[i].controlId, darkStyleProps[i].propertyId, darkStyleProps[i].propertyValue); 311 | } 312 | 313 | // Custom font loading 314 | // NOTE: Compressed font image data (DEFLATE), it requires DecompressData() function 315 | int darkFontDataSize = 0; 316 | unsigned char *data = DecompressData(darkFontData, DARK_COMPRESSED_DATA_SIZE, &darkFontDataSize); 317 | Image imFont = { data, 256, 256, 1, 2 }; 318 | 319 | Font font = { 0 }; 320 | font.baseSize = 16; 321 | font.glyphCount = 95; 322 | 323 | // Load texture from image 324 | font.texture = LoadTextureFromImage(imFont); 325 | UnloadImage(imFont); // Uncompressed data can be unloaded from memory 326 | 327 | // Copy char recs data from global fontRecs 328 | // NOTE: Required to avoid issues if trying to free font 329 | font.recs = (Rectangle *)malloc(font.glyphCount*sizeof(Rectangle)); 330 | memcpy(font.recs, darkFontRecs, font.glyphCount*sizeof(Rectangle)); 331 | 332 | // Copy font char info data from global fontChars 333 | // NOTE: Required to avoid issues if trying to free font 334 | font.glyphs = (GlyphInfo *)malloc(font.glyphCount*sizeof(GlyphInfo)); 335 | memcpy(font.glyphs, darkFontChars, font.glyphCount*sizeof(GlyphInfo)); 336 | 337 | GuiSetFont(font); 338 | 339 | // TODO: Setup a white rectangle on the font to be used on shapes drawing, 340 | // this way we make sure all gui can be drawn on a single pass because no texture change is required 341 | // NOTE: Setting up this rectangle is a manual process (for the moment) 342 | Rectangle whiteChar = { 124, 6, 1, 1 }; 343 | SetShapesTexture(font.texture, whiteChar); 344 | 345 | //----------------------------------------------------------------- 346 | 347 | // TODO: Custom user style setup: Set specific properties here (if required) 348 | // i.e. Controls specific BORDER_WIDTH, TEXT_PADDING, TEXT_ALIGNMENT 349 | } 350 | -------------------------------------------------------------------------------- /Source/rlights/rlights.h: -------------------------------------------------------------------------------- 1 | /********************************************************************************************** 2 | * 3 | * raylib.lights - Some useful functions to deal with lights data 4 | * 5 | * CONFIGURATION: 6 | * 7 | * #define RLIGHTS_IMPLEMENTATION 8 | * Generates the implementation of the library into the included file. 9 | * If not defined, the library is in header only mode and can be included in other headers 10 | * or source files without problems. But only ONE file should hold the implementation. 11 | * 12 | * LICENSE: zlib/libpng 13 | * 14 | * Copyright (c) 2017-2023 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5) 15 | * 16 | * This software is provided "as-is", without any express or implied warranty. In no event 17 | * will the authors be held liable for any damages arising from the use of this software. 18 | * 19 | * Permission is granted to anyone to use this software for any purpose, including commercial 20 | * applications, and to alter it and redistribute it freely, subject to the following restrictions: 21 | * 22 | * 1. The origin of this software must not be misrepresented; you must not claim that you 23 | * wrote the original software. If you use this software in a product, an acknowledgment 24 | * in the product documentation would be appreciated but is not required. 25 | * 26 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented 27 | * as being the original software. 28 | * 29 | * 3. This notice may not be removed or altered from any source distribution. 30 | * 31 | **********************************************************************************************/ 32 | 33 | #ifndef RLIGHTS_H 34 | #define RLIGHTS_H 35 | 36 | //---------------------------------------------------------------------------------- 37 | // Defines and Macros 38 | //---------------------------------------------------------------------------------- 39 | #define MAX_LIGHTS 4 // Max dynamic lights supported by shader 40 | 41 | //---------------------------------------------------------------------------------- 42 | // Types and Structures Definition 43 | //---------------------------------------------------------------------------------- 44 | 45 | // Light data 46 | 47 | #define RLIGHTS_IMPLEMENTATION 48 | 49 | typedef struct { 50 | int type; 51 | bool enabled; 52 | Vector3 position; 53 | Vector3 target; 54 | Color color; 55 | float attenuation; 56 | 57 | // Shader locations 58 | int enabledLoc; 59 | int typeLoc; 60 | int positionLoc; 61 | int targetLoc; 62 | int colorLoc; 63 | int attenuationLoc; 64 | } Light; 65 | 66 | // Light type 67 | typedef enum { 68 | LIGHT_DIRECTIONAL = 0, 69 | LIGHT_POINT 70 | } LightType; 71 | 72 | #ifdef __cplusplus 73 | extern "C" { // Prevents name mangling of functions 74 | #endif 75 | 76 | //---------------------------------------------------------------------------------- 77 | // Module Functions Declaration 78 | //---------------------------------------------------------------------------------- 79 | Light CreateLight(int type, Vector3 position, Vector3 target, Color color, Shader shader); // Create a light and get shader locations 80 | void UpdateLightValues(Shader shader, Light light); // Send light properties to shader 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif // RLIGHTS_H 87 | 88 | 89 | /*********************************************************************************** 90 | * 91 | * RLIGHTS IMPLEMENTATION 92 | * 93 | ************************************************************************************/ 94 | 95 | #if defined(RLIGHTS_IMPLEMENTATION) 96 | 97 | #include "raylib.h" 98 | 99 | //---------------------------------------------------------------------------------- 100 | // Defines and Macros 101 | //---------------------------------------------------------------------------------- 102 | // ... 103 | 104 | //---------------------------------------------------------------------------------- 105 | // Types and Structures Definition 106 | //---------------------------------------------------------------------------------- 107 | // ... 108 | 109 | //---------------------------------------------------------------------------------- 110 | // Global Variables Definition 111 | //---------------------------------------------------------------------------------- 112 | static int lightsCount = 0; // Current amount of created lights 113 | 114 | //---------------------------------------------------------------------------------- 115 | // Module specific Functions Declaration 116 | //---------------------------------------------------------------------------------- 117 | // ... 118 | 119 | //---------------------------------------------------------------------------------- 120 | // Module Functions Definition 121 | //---------------------------------------------------------------------------------- 122 | 123 | // Create a light and get shader locations 124 | Light CreateLight(int type, Vector3 position, Vector3 target, Color color, Shader shader) 125 | { 126 | Light light = { 0 }; 127 | 128 | if (lightsCount < MAX_LIGHTS) 129 | { 130 | light.enabled = true; 131 | light.type = type; 132 | light.position = position; 133 | light.target = target; 134 | light.color = color; 135 | 136 | // NOTE: Lighting shader naming must be the provided ones 137 | light.enabledLoc = GetShaderLocation(shader, TextFormat("lights[%i].enabled", lightsCount)); 138 | light.typeLoc = GetShaderLocation(shader, TextFormat("lights[%i].type", lightsCount)); 139 | light.positionLoc = GetShaderLocation(shader, TextFormat("lights[%i].position", lightsCount)); 140 | light.targetLoc = GetShaderLocation(shader, TextFormat("lights[%i].target", lightsCount)); 141 | light.colorLoc = GetShaderLocation(shader, TextFormat("lights[%i].color", lightsCount)); 142 | 143 | UpdateLightValues(shader, light); 144 | 145 | lightsCount++; 146 | } 147 | 148 | return light; 149 | } 150 | 151 | // Send light properties to shader 152 | // NOTE: Light shader locations should be available 153 | void UpdateLightValues(Shader shader, Light light) 154 | { 155 | // Send to shader light enabled state and type 156 | SetShaderValue(shader, light.enabledLoc, &light.enabled, SHADER_UNIFORM_INT); 157 | SetShaderValue(shader, light.typeLoc, &light.type, SHADER_UNIFORM_INT); 158 | 159 | // Send to shader light position values 160 | float position[3] = { light.position.x, light.position.y, light.position.z }; 161 | SetShaderValue(shader, light.positionLoc, position, SHADER_UNIFORM_VEC3); 162 | 163 | // Send to shader light target position values 164 | float target[3] = { light.target.x, light.target.y, light.target.z }; 165 | SetShaderValue(shader, light.targetLoc, target, SHADER_UNIFORM_VEC3); 166 | 167 | // Send to shader light color values 168 | float color[4] = { (float)light.color.r/(float)255, (float)light.color.g/(float)255, 169 | (float)light.color.b/(float)255, (float)light.color.a/(float)255 }; 170 | SetShaderValue(shader, light.colorLoc, color, SHADER_UNIFORM_VEC4); 171 | } 172 | 173 | #endif // RLIGHTS_IMPLEMENTATION --------------------------------------------------------------------------------