Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.49 KB | None | 0 0
  1. /////////////////////////////
  2. //Main Libary
  3. /////////////////////////////
  4. #include <SDL/SDL.h>
  5. #include <SDL/SDL_image.h>
  6. #include <SDL/SDL_mixer.h>
  7. /////////////////////////////
  8. //Other Files
  9. #include "CollisionFunction.h"
  10. /////////////////////////////
  11. #define SCREEN_HEIGHT 640
  12. #define SCREEN_WIDTH 480
  13. /////////////////////////////
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. SDL_Rect OrangeGhostKnightRect;
  21.  
  22.             //Main Rectangles
  23.             SDL_Rect LevelOneRect;
  24.             SDL_Rect GroundOneRect;
  25.             SDL_Rect GroundTwoRect;
  26.             SDL_Rect GroundThreeRect;
  27.             SDL_Rect GroundFourRect;
  28.  
  29.             //Mario Rect
  30.             SDL_Rect MarioRect;
  31.  
  32.             //Water Rects
  33.             SDL_Rect WaterRect;
  34.             SDL_Rect WaterRect2;
  35.             SDL_Rect WaterRect3;
  36.             SDL_Rect WaterGroundRect;
  37.  
  38.  
  39.             //Storage Rectangles
  40.             SDL_Rect StorageRect1;
  41.             SDL_Rect StorageRect2;
  42.             SDL_Rect StorageRect3;
  43.             SDL_Rect StorageRect4;
  44.             SDL_Rect StorageRect5;
  45.             SDL_Rect StorageRect6;
  46.             SDL_Rect StorageRect7;
  47.             SDL_Rect StorageRect8;
  48.             SDL_Rect StorageRect9;
  49.             SDL_Rect StorageRect10;
  50.  
  51.             //BubbleGumRect Storage
  52.             SDL_Rect StorageRect11;
  53.             SDL_Rect StorageRect12;
  54.  
  55.  
  56.  
  57.             //BoundingBox
  58.             SDL_Rect BoundingBox1;
  59.             SDL_Rect BoundingBox2;
  60.  
  61.             //Timer Rect
  62.             SDL_Rect TimerTextRect;
  63.  
  64.             //Weather Rect
  65.             SDL_Rect BubbleGumCloudRect;
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.          //////////////////////////////////////////////////
  73.                      //Orange Ghost Knight Logic
  74.          /////////////////////////////////////////////////
  75.  
  76. /////////////////////////////////////////////////////////////////
  77. int EnemyFunction(void *unused)
  78.    {
  79.  
  80.    for(int d = 0; d <= 10; d++)
  81.             {
  82.  
  83.     OrangeGhostKnightRect = StorageRect10;
  84.             SDL_BlitSurface(OrangeGhostKnightSurf,NULL,Screen,&OrangeGhostKnightRect);
  85.  
  86.  
  87.  
  88.     if(StorageRect10.x >= 400)
  89.                         {
  90.  
  91.                                StorageRect10.x += 40;
  92.  
  93.                                    OrangeGhostKnightRect = StorageRect10;
  94.             SDL_BlitSurface(OrangeGhostKnightSurf,NULL,Screen,&OrangeGhostKnightRect);
  95.  
  96.                         }
  97.  
  98.  
  99.               if(StorageRect10.x >= 480)
  100.  
  101.                         {
  102.                            StorageRect10.x -=40;
  103.  
  104.                                OrangeGhostKnightRect = StorageRect10;
  105.             SDL_BlitSurface(OrangeGhostKnightSurf,NULL,Screen,&OrangeGhostKnightRect);
  106.  
  107.                         }
  108. }
  109.  
  110.  
  111.          /////////////////////////////////////////////////////////////////////////////////////////
  112.    }
  113.  
  114.  
  115. int orangeghostknightfunction(void *unused)
  116. {
  117.        LevelOneRect = StorageRect1;
  118.             SDL_BlitSurface(LevelOneBG,NULL,Screen,&LevelOneRect);
  119.  
  120.             WaterGroundRect = StorageRect5;
  121.             SDL_BlitSurface(WaterGroundSurf,NULL,Screen,&WaterGroundRect);
  122.  
  123.             GroundOneRect = StorageRect2;
  124.             SDL_BlitSurface(GroundOneBG,NULL,Screen,&GroundOneRect);
  125.  
  126.             GroundTwoRect = StorageRect6;
  127.             SDL_BlitSurface(GroundTwoBG,NULL,Screen,&GroundTwoRect);
  128.  
  129.             GroundThreeRect = StorageRect7;
  130.             SDL_BlitSurface(GroundThreeBG,NULL,Screen,&GroundThreeRect);
  131.  
  132.             MarioRect = StorageRect3;
  133.             SDL_BlitSurface(SuperMarioWalk2Surf,NULL,Screen,&MarioRect);
  134.  
  135.  
  136.             OrangeGhostKnightRect = StorageRect10;
  137.             SDL_BlitSurface(OrangeGhostKnightSurf,NULL,Screen,&OrangeGhostKnightRect);
  138.  
  139.             BubbleGumCloudRect = StorageRect11;
  140.             SDL_BlitSurface(BubbleGumCloudSurf,NULL,Screen,&BubbleGumCloudRect);
  141.  
  142.             SDL_BlitSurface(Text,NULL,Screen,&TimerTextRect);
  143.  
  144.             //Update Screen
  145.             SDL_Flip(Screen);
  146.  
  147.  
  148. }
  149.  
  150.  
  151. ////////////////////////////////////////////////////////////////////////////////////////////////
  152.  
  153.  
  154. int LevelOneFunction(void *unused)
  155. {
  156.  
  157.             ////////////////////////////////////////////////////////////////////////////////
  158.             //Color Selections
  159.             Uint32 RedColor =SDL_MapRGB(Screen->format,255,0,0);
  160.             Uint32 OrangeColor =SDL_MapRGB(Screen->format,255,100,0);
  161.             Uint32 BlackColor =SDL_MapRGB(Screen->format,0,0,0);
  162.             Uint32 GreyColor = SDL_MapRGB(Screen->format,192,192,192);
  163.             Uint32 MintGreenColor = SDL_MapRGB(Screen->format,39,216,176);
  164.             Uint32 LightOliveGreenColor = SDL_MapRGB(Screen->format,135,179,77);
  165.  
  166.             //SDL COLOR Colors
  167.              SDL_Color WhiteColor = {255,255,255};
  168.             ////////////////////////////////////////////////////////////////////////////////
  169.  
  170.             ////////////////////////
  171.             //Storage Rect Positions
  172.             ///////////////////////
  173.  
  174.             StorageRect1.x = 0;
  175.             StorageRect1.y = 0;
  176.  
  177.             StorageRect2.x = 0;
  178.             StorageRect2.y = 380;
  179.  
  180.             StorageRect3.x = 0;
  181.             StorageRect3.y = 310;
  182.  
  183.             StorageRect4.x = 0;
  184.             StorageRect4.y = 360;
  185.  
  186.             StorageRect5.x = 0;
  187.             StorageRect5.y = 400;
  188.  
  189.             StorageRect6.x = 320;
  190.             StorageRect6.y = 400;
  191.  
  192.             StorageRect7.x = 580;
  193.             StorageRect7.y = 400;
  194.  
  195.             StorageRect10.x = 400;
  196.             StorageRect10.y = 320;
  197.  
  198.             StorageRect11.y = -200;
  199.  
  200.             StorageRect12.x = 5;
  201.  
  202.             ///////////////////////////////
  203.  
  204.             //BoundingBox 1 Values
  205.             BoundingBox1.x =160;
  206.             BoundingBox1.y =360;
  207.             BoundingBox1.w = 60;
  208.             BoundingBox1.h = 108;
  209.  
  210.             //BoundingBox 2 Values
  211.             BoundingBox2.x =300;
  212.             BoundingBox2.y =300;
  213.             BoundingBox2.w = 60;
  214.             BoundingBox2.h = 120;
  215.  
  216.  
  217.             //Mario Rect Values
  218.             MarioRect.x = 0;
  219.             MarioRect.y = 0;
  220.  
  221.             //LevelOneBG Values
  222.             LevelOneRect.x = 0;
  223.             LevelOneRect.y = 0;
  224.  
  225.             //PurpleAmal Rock 1 Values
  226.             GroundOneRect.x = 0;
  227.             GroundOneRect.y = 0;
  228.  
  229.             ////////////////////////////
  230.  
  231.  
  232.  
  233.  
  234.  
  235.    //Bool Variable
  236.     bool done = false;
  237.  
  238.     //Event Creation
  239.     SDL_Event event;
  240.  
  241.      while(!done)
  242.             {
  243.  
  244.             //Other Stuff
  245.             StorageRect11.x += 1;
  246.  
  247.              SDL_Thread *TestThread;
  248.        TestThread = SDL_CreateThread(orangeghostknightfunction,NULL);
  249.  
  250.        SDL_WaitThread(TestThread,NULL);
  251.  
  252.        SDL_Flip(Screen);
  253.  
  254.        SDL_KillThread(TestThread);
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.             //Collision Testing
  263.             SDL_FillRect(Screen,&BoundingBox2,MintGreenColor);
  264.  
  265.  
  266.  
  267.         ////////////////////////////////////////////////////
  268.        //While continous events are running in event
  269.        ////////////////////////////////////////////////////
  270.  
  271.           while(SDL_PollEvent(&event))
  272.           {
  273.  
  274.  
  275.  
  276.             //allow to be able to switch events
  277.             switch(event.type)
  278.             {
  279.  
  280.             ////////////////////////////////////
  281.  
  282.             //While Any Key is Down
  283.             case SDL_KEYDOWN:
  284.  
  285.             //Allow Keyboard Events
  286.             switch(event.key.keysym.sym)
  287.             {
  288.  
  289.                 //Up is Pressed
  290.                    case SDLK_RIGHT:
  291.  
  292.                      //Movements of actual visual objects
  293.                     StorageRect3.x +=10;
  294.                     StorageRect3.y += 5;
  295.                     StorageRect1.x -=6;
  296.                     StorageRect2.x -=2;
  297.                     StorageRect4.x -=1;
  298.                     StorageRect5.x -= 4;
  299.                     StorageRect6.x -=2;
  300.                     StorageRect7.x -=2;
  301.                     BoundingBox2.x -=2;
  302.  
  303.                     /////////////////////////////////////////////////
  304.  
  305.                              //Movements of BoundingBoxes
  306.  
  307.  
  308.                     if(StorageRect3.x > SCREEN_WIDTH)
  309.                     {
  310.                         StorageRect3.x -=20;
  311.                         StorageRect2.x -=3;
  312.                         StorageRect6.x -=3;
  313.                         StorageRect1.x -=10;
  314.                     }
  315.  
  316.  
  317.  
  318.  
  319.  
  320.                      ////////////////////////////
  321.                     //Collision Boxes
  322.                     ////////////////////////////
  323.  
  324.                     if(Check_Collision(MarioRect,GroundOneRect))
  325.                     {
  326.                         StorageRect3.y -= 5;
  327.                     }
  328.  
  329.  
  330.                     if(Check_Collision(MarioRect,BoundingBox1))
  331.                     {
  332.                         StorageRect3.y += 6;
  333.                     }
  334.  
  335.  
  336.  
  337.  
  338.                ////////////////////////
  339.  
  340.                //KEYSYSTEM EVENTS ^^
  341.                     }
  342.  
  343.  
  344.             //SDL KEYDOWN
  345.                     break;
  346.  
  347.                       ////////////////////////////////
  348.  
  349.                 //if user presses on close
  350.                 case SDL_QUIT:
  351.  
  352.                     //Close Application
  353.                     return 0;
  354.  
  355.  
  356.                         //break case
  357.                         break;
  358.  
  359.          //SWITCH EVENT TYPE
  360.  
  361.             }
  362.  
  363.  
  364.  
  365. /////////
  366. //POLL
  367. /////////
  368.  
  369.  
  370.  
  371.                                 }
  372.  
  373.  
  374. //////////////////////////////////////
  375. //END OF THE MAIN WHILE LOOP
  376. /////////////////////////////////////
  377.  
  378.  
  379.             }
  380. /////////////////////////////////////
  381.  
  382.  
  383. //DONT KNOW
  384. //COULD BE THE RIGHT POINT
  385.  
  386.  
  387. }
  388.  
  389. ////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement