Giter Site home page Giter Site logo

raylib-super-mario-clone's Introduction

Raylib-Super-Mario-Clone

Super mario clone made using raylib 3.0

Assets are from VideoGameSprites.net

Required Libraries :

  • Raylib 3.0

All installation and other important details are available from Raylib's github page.

How to run :

It is recommended to install Raylib using Homebrew

With Homebrew
  • If you don't want to build it yourself, install Homebrew by executing the following command in Terminal.app:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Once Homebrew is installed, run the following command in Terminal:
brew install raylib

How to compile Raylib using Clang (or on MacOSX)

C

clang -std=c11 -framework IOKit -framework Cocoa -framework OpenGL /usr/local/Cellar/raylib/3.0.0/lib/libraylib.a  <All C files> -o my_app && ./my_app

C++

clang -std=c++11 -framework CoreVideo -framework IOKit -framework Cocoa -framework GLUT -framework OpenGL  /path/to/libraylib.a <All C++ files> -o my_app

On Windows :

gcc -o my_app.exe <All C/C++ files> -s C:\raylib\raylib\raylib_icon -Iexternal -lraylib -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,-allow-multiple-definition -Wl,--subsystem,windows

raylib-super-mario-clone's People

Contributors

pikachuxxxx avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

juwon0102

raylib-super-mario-clone's Issues

Simultaneous states are not supported by the StateMachine

Issue :
The state machine which controls the Animations and Movement of the player does not allow multiple states to work simultaneously. Player cannot Jump from Walking state and cannot move while in midair i.e. while in Jumping state.

Desired Solution :
Proper state transition paths and rules must be programmed with the state machine.

Player Collisions is not detected, Needs Refactoring of Player Struct

Issue :

  • When using the same Rectangle that is uses to draw the Animated SpriteSheet in DrawTextureRec() that Rectanlge cannot be used for collision detection.

Proposed Solution :

  • The player struct must be refactored to have 2 Rects. 1 for rendering the sprite sheet animation and another for Collision Detection.

Static Variables Overriding for different Textures in SpriteAnimations

void AnimateSpriteSheetRec(Texture2D spriteSheet, Rectangle *frameRec, int framesSpeed, int frames);

Implementation Code :

void AnimateSpriteSheetRec(Texture2D spriteSheet, Rectangle *frameRec, int framesSpeed, int frames){
  static float framesCounter = 0;
  static int currentFrame = 0;

  *frameRec = (Rectangle){ 0.0f, 0.0f, (float)spriteSheet.width/frames, (float)spriteSheet.height };

  framesCounter +=  GetFrameTime();

   if (framesCounter >= (float)framesSpeed/100)
   {
       framesCounter = 0;
       currentFrame++;

       if (currentFrame > frames - 1) currentFrame = 0;
   }
   frameRec->x = (float)currentFrame*(float)spriteSheet.width/frames;
}

Issue :
This function uses Static variables for frameRateCounter and currentFrame counting which makes this is ideal if is being used to animate a single sprite sheet with the intention of avoiding global variables, but the static variables values get overwritten/ influenced if the function is called multiple times to animate other sprites sheets/ Different Textures making this function Non-Generic, also using global variables for frame and rate counting for 100's of sprites sheets would be absurd.

Desired Solution:
It is necessary to make this function more Generic by making it retain certain values (for now 2 variables for rate and frameCount) separately for each instance call if new Texture is passed to is. So for every new texture how many ever times it may be called it must retain a few variables, i.e must have local static variables for every new texture passed.

Current Workaround:

  • If using this function to animate different instances of same Texture multiply the base frameSpeed by number of instances to get the same effect as if using a single texture.
  • This is same as increasing frame speed delay proportional to increased number of function calls.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.