Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////////////////////////////
- //Main Libary
- /////////////////////////////
- #include <SDL/SDL.h>
- #include <SDL/SDL_image.h>
- #include <SDL/SDL_mixer.h>
- /////////////////////////////
- //Other Files
- #include "CollisionFunction.h"
- /////////////////////////////
- #define SCREEN_HEIGHT 640
- #define SCREEN_WIDTH 480
- /////////////////////////////
- SDL_Rect OrangeGhostKnightRect;
- //Main Rectangles
- SDL_Rect LevelOneRect;
- SDL_Rect GroundOneRect;
- SDL_Rect GroundTwoRect;
- SDL_Rect GroundThreeRect;
- SDL_Rect GroundFourRect;
- //Mario Rect
- SDL_Rect MarioRect;
- //Water Rects
- SDL_Rect WaterRect;
- SDL_Rect WaterRect2;
- SDL_Rect WaterRect3;
- SDL_Rect WaterGroundRect;
- //Storage Rectangles
- SDL_Rect StorageRect1;
- SDL_Rect StorageRect2;
- SDL_Rect StorageRect3;
- SDL_Rect StorageRect4;
- SDL_Rect StorageRect5;
- SDL_Rect StorageRect6;
- SDL_Rect StorageRect7;
- SDL_Rect StorageRect8;
- SDL_Rect StorageRect9;
- SDL_Rect StorageRect10;
- //BubbleGumRect Storage
- SDL_Rect StorageRect11;
- SDL_Rect StorageRect12;
- //BoundingBox
- SDL_Rect BoundingBox1;
- SDL_Rect BoundingBox2;
- //Timer Rect
- SDL_Rect TimerTextRect;
- //Weather Rect
- SDL_Rect BubbleGumCloudRect;
- //////////////////////////////////////////////////
- //Orange Ghost Knight Logic
- /////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
- int EnemyFunction(void *unused)
- {
- for(int d = 0; d <= 10; d++)
- {
- OrangeGhostKnightRect = StorageRect10;
- SDL_BlitSurface(OrangeGhostKnightSurf,NULL,Screen,&OrangeGhostKnightRect);
- if(StorageRect10.x >= 400)
- {
- StorageRect10.x += 40;
- OrangeGhostKnightRect = StorageRect10;
- SDL_BlitSurface(OrangeGhostKnightSurf,NULL,Screen,&OrangeGhostKnightRect);
- }
- if(StorageRect10.x >= 480)
- {
- StorageRect10.x -=40;
- OrangeGhostKnightRect = StorageRect10;
- SDL_BlitSurface(OrangeGhostKnightSurf,NULL,Screen,&OrangeGhostKnightRect);
- }
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- }
- int DrawAndUpdate (void *unused)
- {
- LevelOneRect = StorageRect1;
- SDL_BlitSurface(LevelOneBG,NULL,Screen,&LevelOneRect);
- WaterGroundRect = StorageRect5;
- SDL_BlitSurface(WaterGroundSurf,NULL,Screen,&WaterGroundRect);
- GroundOneRect = StorageRect2;
- SDL_BlitSurface(GroundOneBG,NULL,Screen,&GroundOneRect);
- GroundTwoRect = StorageRect6;
- SDL_BlitSurface(GroundTwoBG,NULL,Screen,&GroundTwoRect);
- GroundThreeRect = StorageRect7;
- SDL_BlitSurface(GroundThreeBG,NULL,Screen,&GroundThreeRect);
- MarioRect = StorageRect3;
- SDL_BlitSurface(SuperMarioWalk2Surf,NULL,Screen,&MarioRect);
- OrangeGhostKnightRect = StorageRect10;
- SDL_BlitSurface(OrangeGhostKnightSurf,NULL,Screen,&OrangeGhostKnightRect);
- BubbleGumCloudRect = StorageRect11;
- SDL_BlitSurface(BubbleGumCloudSurf,NULL,Screen,&BubbleGumCloudRect);
- SDL_BlitSurface(Text,NULL,Screen,&TimerTextRect);
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////
- int LevelOneFunction(void *unused)
- {
- ////////////////////////////////////////////////////////////////////////////////
- //Color Selections
- Uint32 RedColor =SDL_MapRGB(Screen->format,255,0,0);
- Uint32 OrangeColor =SDL_MapRGB(Screen->format,255,100,0);
- Uint32 BlackColor =SDL_MapRGB(Screen->format,0,0,0);
- Uint32 GreyColor = SDL_MapRGB(Screen->format,192,192,192);
- Uint32 MintGreenColor = SDL_MapRGB(Screen->format,39,216,176);
- Uint32 LightOliveGreenColor = SDL_MapRGB(Screen->format,135,179,77);
- //SDL COLOR Colors
- SDL_Color WhiteColor = {255,255,255};
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////
- //Storage Rect Positions
- ///////////////////////
- StorageRect1.x = 0;
- StorageRect1.y = 0;
- StorageRect2.x = 0;
- StorageRect2.y = 380;
- StorageRect3.x = 0;
- StorageRect3.y = 310;
- StorageRect4.x = 0;
- StorageRect4.y = 360;
- StorageRect5.x = 0;
- StorageRect5.y = 400;
- StorageRect6.x = 320;
- StorageRect6.y = 400;
- StorageRect7.x = 580;
- StorageRect7.y = 400;
- StorageRect10.x = 400;
- StorageRect10.y = 320;
- StorageRect11.y = -200;
- StorageRect12.x = 5;
- ///////////////////////////////
- //BoundingBox 1 Values
- BoundingBox1.x =160;
- BoundingBox1.y =360;
- BoundingBox1.w = 60;
- BoundingBox1.h = 108;
- //BoundingBox 2 Values
- BoundingBox2.x =300;
- BoundingBox2.y =300;
- BoundingBox2.w = 60;
- BoundingBox2.h = 120;
- //Mario Rect Values
- MarioRect.x = 0;
- MarioRect.y = 0;
- //LevelOneBG Values
- LevelOneRect.x = 0;
- LevelOneRect.y = 0;
- //PurpleAmal Rock 1 Values
- GroundOneRect.x = 0;
- GroundOneRect.y = 0;
- ////////////////////////////
- //Bool Variable
- bool done = false;
- //Event Creation
- SDL_Event event;
- while(!done)
- {
- //Other Stuff
- StorageRect11.x += 1;
- SDL_Thread *TestThread;
- TestThread = SDL_CreateThread(DrawAndUpdate,NULL);
- //Update Screen
- SDL_Flip(Screen);
- //Collision Testing
- SDL_FillRect(Screen,&BoundingBox2,MintGreenColor);
- ////////////////////////////////////////////////////
- //While continous events are running in event
- ////////////////////////////////////////////////////
- while(SDL_PollEvent(&event))
- {
- //allow to be able to switch events
- switch(event.type)
- {
- ////////////////////////////////////
- //While Any Key is Down
- case SDL_KEYDOWN:
- //Allow Keyboard Events
- switch(event.key.keysym.sym)
- {
- //Up is Pressed
- case SDLK_RIGHT:
- //Movements of actual visual objects
- StorageRect3.x +=10;
- StorageRect3.y += 5;
- StorageRect1.x -=6;
- StorageRect2.x -=2;
- StorageRect4.x -=1;
- StorageRect5.x -= 4;
- StorageRect6.x -=2;
- StorageRect7.x -=2;
- BoundingBox2.x -=2;
- /////////////////////////////////////////////////
- //Movements of BoundingBoxes
- if(StorageRect3.x > SCREEN_WIDTH)
- {
- StorageRect3.x -=20;
- StorageRect2.x -=3;
- StorageRect6.x -=3;
- StorageRect1.x -=10;
- }
- ////////////////////////////
- //Collision Boxes
- ////////////////////////////
- if(Check_Collision(MarioRect,GroundOneRect))
- {
- StorageRect3.y -= 5;
- }
- if(Check_Collision(MarioRect,BoundingBox1))
- {
- StorageRect3.y += 6;
- }
- ////////////////////////
- //KEYSYSTEM EVENTS ^^
- }
- //SDL KEYDOWN
- break;
- ////////////////////////////////
- //if user presses on close
- case SDL_QUIT:
- //Close Application
- return 0;
- //break case
- break;
- //SWITCH EVENT TYPE
- }
- /////////
- //POLL
- /////////
- }
- //////////////////////////////////////
- //END OF THE MAIN WHILE LOOP
- /////////////////////////////////////
- }
- /////////////////////////////////////
- //DONT KNOW
- //COULD BE THE RIGHT POINT
- }
- ////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement