c_cpp 老鲍勃塔主要
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 老鲍勃塔主要相关的知识,希望对你有一定的参考价值。
// Saved just for fun to look at it later
////////////////////////////////////////////////////////////////////////////////
// //
// //
// Bob's Adventure Prototype //
// by Coldragon //
// main2.c remake //
// //
// //
////////////////////////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
struct leBob
{
SDL_Rect pos, posTemp;
SDL_Surface *skinUp;
SDL_Surface *skinDown;
SDL_Surface *skinLeft;
SDL_Surface *skinRight;
SDL_Surface *skinActual;
int speed;
int caseNow;
int caseNext;
};
struct leSol
{
int tileType;
SDL_Rect pos;
SDL_Surface *skin;
};
struct leObj
{
int objType;
SDL_Rect pos;
SDL_Surface *skin;
};
int main(int argc, char *argv[])
{
//Variables Initial
SDL_Event event;
SDL_Surface
*ecran = NULL;
struct leSol SOL1, SOL2, SOL3;
struct leBob BOB1;
struct leObj OBJ1;
int i, j, continuer;
continuer = 1;
int map1[15][25] =
{
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1},
{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
};
//Init SDL et ecran
SDL_Init(SDL_INIT_VIDEO);
ecran = SDL_SetVideoMode(800, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_WM_SetCaption("Bob's Adventure Proto 1", NULL);
// Init Variable struct
SOL1.skin=SDL_LoadBMP("res/sol1.bmp");
SOL2.skin=SDL_LoadBMP("res/sol2.bmp");
SOL3.skin=SDL_LoadBMP("res/sol3.bmp");
// Skin de Bob
BOB1.skinDown=SDL_LoadBMP("res/bob_down.bmp");
BOB1.skinUp=SDL_LoadBMP("res/bob_up.bmp");
BOB1.skinLeft=SDL_LoadBMP("res/bob_left.bmp");
BOB1.skinRight=SDL_LoadBMP("res/bob_right.bmp");
BOB1.skinActual=SDL_LoadBMP("res/bob_down.bmp");
SDL_SetColorKey(BOB1.skinUp, SDL_SRCCOLORKEY, SDL_MapRGB(BOB1.skinUp->format, 255, 0, 255));
SDL_SetColorKey(BOB1.skinDown, SDL_SRCCOLORKEY, SDL_MapRGB(BOB1.skinDown->format, 255, 0, 255));
SDL_SetColorKey(BOB1.skinLeft, SDL_SRCCOLORKEY, SDL_MapRGB(BOB1.skinLeft->format, 255, 0, 255));
SDL_SetColorKey(BOB1.skinRight, SDL_SRCCOLORKEY, SDL_MapRGB(BOB1.skinRight->format, 255, 0, 255));
SDL_SetColorKey(BOB1.skinActual, SDL_SRCCOLORKEY, SDL_MapRGB(BOB1.skinActual->format, 255, 0, 255));
BOB1.pos.x = ecran->w / 2 - BOB1.skinDown->w / 2;
BOB1.pos.y = ecran->h / 2 - BOB1.skinDown->h / 2;
SDL_EnableKeyRepeat(5, 5); /* Activation de la répétition des touches */
// Boucle Principal
while (continuer)
{
//Event 1
SDL_WaitEvent(&event);
BOB1.posTemp.y=BOB1.pos.y;
BOB1.posTemp.x=BOB1.pos.x;
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym)
{
case SDLK_UP:
printf("PRESS HAUT \n");
BOB1.pos.y=BOB1.pos.y-1;
BOB1.skinActual=BOB1.skinUp;
break;
case SDLK_DOWN:
printf("PRESS BAS \n");
BOB1.pos.y=BOB1.pos.y+1;
BOB1.skinActual=BOB1.skinDown;
break;
case SDLK_RIGHT:
printf("PRESS DROITE \n");
BOB1.pos.x=BOB1.pos.x+1;
BOB1.skinActual=BOB1.skinRight;
break;
case SDLK_LEFT:
printf("PRESS GAUCHE \n");
BOB1.pos.x=BOB1.pos.x-1;
BOB1.skinActual=BOB1.skinLeft;
break;
}
break;
//Fin switch
}
// Affichage map1
for (i=0; i<15; i++)
{
for (j=0; j<25; j++)
{
SOL1.pos.x=j*32;
SOL1.pos.y=i*32;
SOL2.pos.x=j*32;
SOL2.pos.y=i*32;
if (map1[i][j] == 0)
SDL_BlitSurface(SOL1.skin, NULL, ecran, &SOL1.pos);
if (map1[i][j] == 1)
SDL_BlitSurface(SOL2.skin, NULL, ecran, &SOL2.pos);
printf("mapUpdate \n");
}
}
// Afficher Joueur
SDL_BlitSurface(BOB1.skinActual, NULL, ecran, &BOB1.pos);
SDL_Flip(ecran);
//Fin Boucl Principal
}
//Quit SDL_Init et libération SDL_Surface
SDL_FreeSurface(SOL1.skin);
SDL_FreeSurface(SOL2.skin);
SDL_FreeSurface(SOL3.skin);
SDL_FreeSurface(BOB1.skinActual);
SDL_FreeSurface(OBJ1.skin);
SDL_Quit();
return EXIT_SUCCESS;
}
// // END // //
以上是关于c_cpp 老鲍勃塔主要的主要内容,如果未能解决你的问题,请参考以下文章
请问大佬有流浪猫鲍勃2016年上映的由 卢克·崔德威主演的高清视频在线观看资源吗
c_cpp 以递归方式做河内塔问题的基准.n = 20来自维基百科的伪代码:https://zh.wikipedia.org/wiki/汉诺塔