r/learnprogramming • u/TheSum239 • 19m ago
is there a problem in coding C++ without understanding my code?
#include <raylib.h>
#include <iostream>
#include "classesANDtypes.h"
Music nature;
#include "game.h"
#include "SpritesANDimages&soudns.h"
#include "shadows&shaders.h"
// * my game is still empty and there is no gameplay yet its not considered a game i need to work harder, Omar~
/*
TODO notes: we first starts with a screen to pick up the screen resultion through buttons then we jump into the "Play" button.
TODO ofc when we click the play button we have to remove the buttons from the screen after entering the main game
! which can be done by making a bool statment called IS_PLAY_CLICKED and edit the draw functions using it
*/
// yo iam here
// ? x and y and z are the axis for 3D
// ~ special or important function
// TODO uhhh do later
// ! attention
// ? idk or info
// ^ a code that is crucial
// & function
// * quotes / chat
// useless comment or a code that is turned off
Texture2D paperT;
int main(void)
{
// screen_resolutions = 5
int current_screen = 0;
int scale = 4;
int screen_weight{900};
int screen_hight{900};
bool IS_PLAY_BUTTON_PRESSED = false;
ChangeDirectory(GetApplicationDirectory());
InitWindow(screen_weight, screen_hight, "engimatica");
InitAudioDevice();
loadAll();
CreateCam();
meshbounds();
//insertShadows();
SetTargetFPS(60);
// button
Rectangle btn = {(float)screen_weight / 2 - 150, (float)screen_hight / 2 - 100, 300, 200};
Vector2 mousePoint = {0.0f, 0.0f};
PlayMusicStream(nature);
float volume = 0.8f;
SetMusicVolume(nature, volume);
while (!WindowShouldClose())
{
UpdateMusicStream(nature);
Rectangle PLAY_BUTTON = {(float)screen_weight / 2 - 105, (float)screen_hight / 2 + 140, 200, 90};
mousePoint = GetMousePosition();
if (IS_PLAY_BUTTON_PRESSED != true)
{
if (CheckCollisionPointRec(mousePoint, btn))
{
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
{
current_screen++;
changeScreen(screen_weight, screen_hight, current_screen, scale);
int monitor = GetCurrentMonitor();
int monitorW = GetMonitorWidth(monitor);
int monitorH = GetMonitorHeight(monitor);
SetWindowPosition(
monitorW / 2 - screen_weight / 2,
monitorH / 2 - screen_hight / 2);
}
}
if (CheckCollisionPointRec(mousePoint, PLAY_BUTTON))
{
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
{
IS_PLAY_BUTTON_PRESSED = true;
// ~ game starts
}
}
}
//loadSIM();
SetWindowSize(screen_weight, screen_hight);
BeginDrawing();
ClearBackground(SKYBLUE);
DrawTextureEx(sky2, {0, 0}, 0, scale, WHITE);
// ? GUI
if (IS_PLAY_BUTTON_PRESSED != true)
{
DrawTexture(sky, 0, 0, WHITE);
//DrawRectangle(screen_weight/2 - 440, screen_hight/2 - 150, 200, 300, RED);
DrawTexture(controls, screen_weight/2 - 440, screen_hight/2 - 150, WHITE);
DrawText("Controls:", screen_weight/2 - 430, screen_hight/2 - 130, 25, BLACK);
DrawText("F - disable/enable", screen_weight/2 - 430, screen_hight/2 - 90, 20, BLACK);
DrawText("inventory", screen_weight/2 - 430, screen_hight/2 -70, 20, BLACK);
DrawText("WASD - move cam", screen_weight/2 - 430, screen_hight/2 - 40, 20, BLACK);
DrawText("E / Q - up & down", screen_weight/2 - 430, screen_hight/2 - 10, 20, BLACK);
DrawText("C / V - rotate", screen_weight/2 - 430, screen_hight/2 + 30, 20, BLACK);
DrawText("TAB - show FPS", screen_weight/2 - 430, screen_hight/2 + 60, 20, BLACK);
//DrawRectangle(screen_weight / 2 - 150, screen_hight / 2 - 100, 300, 200, YELLOW);
DrawTexture(Resbutton, screen_weight/2 - 150, screen_hight/2 - 100, WHITE); // screen button
DrawTexture(PlayB, screen_weight / 2 - 105, screen_hight / 2 + 140, WHITE); // play button
DrawText("Play", screen_weight / 2 - 60, screen_hight / 2 + 160, 45, WHITE); // play text
DrawText("Screen resolution", screen_weight / 2 - 150, screen_hight / 2 - 30, 33, WHITE); // screen text
DrawText(TextFormat("%d x %d", screen_weight, screen_hight), screen_weight / 2 - 60, screen_hight / 2 + 10, 20, WHITE); // show res
btn = {(float)screen_weight / 2 - 150, (float)screen_hight / 2 - 100, 300, 200};
PLAY_BUTTON = {(float)screen_weight / 2 - 150, (float)screen_hight / 2 - 150, 250, 150};
}
// ~ Game
if (IS_PLAY_BUTTON_PRESSED != false)
{
game();
}
DrawTexture(crusor, GetMouseX(), GetMouseY(), WHITE);
HideCursor();
if(IsKeyDown(KEY_TAB))
{
DrawFPS(30, 30);
}
EndDrawing();
}
UnloadModel(stoney);
UnloadTexture(grass);
UnloadModel(rock);
UnloadModel(smallTree);
UnloadShader(shader);
UnloadTexture(rockT);
UnloadModel(drill);
UnloadTexture(paperT);
UnloadTexture(sky);
UnloadModel(tree);
UnloadSound(open);
UnloadSound(MapOpen);
UnloadMusicStream(nature);
UnloadTexture(solar);
CloseAudioDevice();
CloseWindow();
return 0;
}this was a sample of my code
i learned C++ from 0 by myself when i was 13 or smth like that and its time to confess that iam coding my game while iam not understanding anything iam doing XD (i dont use AI bc i think its cheating and unfun)