Untitled

 avatar
unknown
plain_text
5 months ago
2.1 kB
5
Indexable
//#include "raylib"
#include "C:\raylib\include\raylib.h"
#include<stdio.h>


int main(void){

    const int screenWidth = 800;

    const int screenHeight = 600;
    InitWindow(screenWidth, screenHeight, "testing abilities");
    SetTargetFPS(60);               // Set our game to run at 60 frames-per-second

    /* LOADING TEXTURES */
  
    //Texture title = LoadTexture("resources/textures/title.png");


    /*    VARIABLES*/

    
    bool onGround = false;
    bool jumping = false;

    int veloY = 0;
    int gravity = 8;
    /*  SHAPES N THINGS */
    
    Vector2 circlePos{150, 100};

    Rectangle platfrom = {120, 400, 200, 20}; //orange

    Rectangle platfrom2 = {350, 450, 300, 15};

    // Main game loop
    while (!WindowShouldClose())    // Detect window close button or ESC key
    {
                             //update variables???
        float deltatime = GetFrameTime();

        //veloY += gravity;
        circlePos.y += veloY * deltatime;

        //if (onGround) veloY = -1;
        if (!onGround) veloY += gravity;

        //if (veloY < 5) veloY = 0;

        if (IsKeyDown(KEY_A)) circlePos.x -= 5;
        if (IsKeyDown(KEY_D)) circlePos.x += 5;
        if (IsKeyDown(KEY_W) && onGround){
            veloY += -100;
            onGround = false;
            //jumping = true;
            
        } 


        onGround = CheckCollisionCircleRec(circlePos, 10, platfrom) || 
        CheckCollisionCircleRec(circlePos, 10, platfrom2);
        
        //if (onGround && IsKeyDown(KEY_D)) circlePos.x -= 5;
        //if (onGround && IsKeyDown(KEY_A)) circlePos.x += 5;
        
        


        //_____________________________________________________
        BeginDrawing();//y

        ClearBackground(RAYWHITE);

        DrawCircleV(circlePos, 10, PURPLE); 

        DrawRectangleRec(platfrom, ORANGE);

        DrawRectangleRec(platfrom2, ORANGE);
   
        EndDrawing();
        //----------------------------------------------------------------------------------

    }





    // De-Initialization
    CloseWindow();        // Close window and OpenGL context
    return 0;
}
Editor is loading...
Leave a Comment