Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<stdio.h>
- #include<string>
- #include<SDL2/SDL.h>
- #include<SDL2/SDL_image.h>
- const int screen_width=1280;
- const int screen_height=680;
- SDL_Window* window=NULL;
- SDL_Renderer* render=NULL;
- SDL_Texture* tex=NULL;
- bool init();
- bool loadMedia();
- void closes();
- int Menu();
- int level1();
- void build_level1();
- bool init()
- {
- bool success = true;
- if(SDL_Init(SDL_INIT_VIDEO)<0)
- {
- success= false;
- printf("%s\n", SDL_GetError());
- }
- else
- {
- if( !SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" ) )
- {
- printf( "Warning: Linear texture filtering not enabled!" );
- }
- window= SDL_CreateWindow("Bouncee", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screen_width, screen_height, SDL_WINDOW_SHOWN);
- if(window==NULL)
- {
- success =false;
- printf("%s\n", SDL_GetError());
- }
- else
- {
- render=SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
- if(render==NULL)
- {
- success=false;
- printf("%s\n", SDL_GetError());
- }
- else
- {
- SDL_SetRenderDrawColor( render, 0x66, 0xF2, 0xFF, 0xFF );
- int imgFlags = IMG_INIT_PNG;
- if( !( IMG_Init( imgFlags ) & imgFlags ) )
- {
- printf( "%s\n", IMG_GetError() );
- success = false;
- }
- }
- }
- }
- return success;
- }
- bool loadMedia()
- {
- bool success=true;
- {
- //I'll have to worry about this part later
- }
- return success;
- }
- void closes()
- {
- SDL_DestroyTexture(tex);
- tex=NULL;
- SDL_DestroyRenderer(render);
- render=NULL;
- SDL_DestroyWindow(window);
- window=NULL;
- IMG_Quit();
- SDL_Quit();
- }
- int Menu()
- {
- int success=1;
- //I'll have to worry about this part later
- return success;
- }
- int level1()
- {
- printf("aisdhfiasdfa\n");
- bool quit=false;
- SDL_Event e;
- while(!quit)
- {
- while(SDL_PollEvent(&e)!=0)
- {
- if(e.type==SDL_QUIT)
- {
- quit=true;
- return 3;
- }
- build_level1();
- SDL_RenderPresent(render);
- }
- }
- if(quit==true) {return 3;}
- }
- void build_level1()
- {
- SDL_Rect ground[10];
- SDL_SetRenderDrawColor( render, 0x66, 0xFF, 0xFF, 0xFF );
- SDL_RenderClear(render);
- ground[0]={0, 600, 100, 40};
- SDL_SetRenderDrawColor(render, 0x66, 0xFF, 0x66, 0xFF);
- SDL_RenderFillRect(render, &ground[0]);
- ground[1]={120, 480, 100, 40};
- SDL_SetRenderDrawColor(render, 0x00, 0x00, 0x00, 0xFF);
- SDL_RenderFillRect(render, &ground[1]);
- ground[2]={180, 400, 100, 40};
- SDL_SetRenderDrawColor(render, 0x66, 0x00, 0x00, 0xFF);
- SDL_RenderFillRect(render, &ground[2]);
- ground[3]={240, 320, 1000, 40};
- SDL_SetRenderDrawColor(render, 0x66, 0x00, 0x00, 0xFF);
- SDL_RenderFillRect(render, &ground[3]);
- ground[4]={320, 400, 100, 40};
- SDL_SetRenderDrawColor(render, 0x66, 0x00, 0x00, 0xFF);
- SDL_RenderFillRect(render, &ground[4]);
- ground[5]={400, 300, 100, 40};
- SDL_SetRenderDrawColor(render, 0x66, 0x00, 0x00, 0xFF);
- SDL_RenderFillRect(render, &ground[5]);
- }
- int main()
- {
- printf("in main\n");
- int indicator=1;
- int levelUpVar;
- if(init())
- {
- printf("in init()\n");
- if(loadMedia())
- {
- printf("in loadMedia()\n");
- while(indicator)
- {
- if(Menu())
- {
- levelUpVar=level1();
- printf("crossed level\n");
- if(levelUpVar==1)
- {
- }
- else if(levelUpVar==2)
- {
- //display_Game_over();
- }
- else if(levelUpVar==3)
- {
- closes();
- return 0;
- }
- }
- else indicator=0;
- }
- }
- }
- closes();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement