Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Tank War Beta v0.1
- // Created by Lars Knaup
- // on 19.02.2011
- // sprites by Timo Keim
- #include <oslib/oslib.h>
- #define HSIZE 480
- #define VSIZE 272
- PSP_MODULE_INFO("TankWar", 0, 1, 1);
- PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
- OSL_IMAGE* panzer;
- OSL_IMAGE* background;
- int positionx = HSIZE / 2;
- int positiony = VSIZE / 2;
- // Funktion: ReadKeys
- // Aufgabe: Reagieren auf Tasten
- // L und R: Rotieren
- // Analog Stick: Fahren
- // X: Schießen
- void ReadKeys()
- {
- oslReadKeys();
- // Bewegung
- if ((osl_keys->held.right) && (positionx < 450)) positionx +=1;
- if ((osl_keys->held.left) && (positionx > 0)) positionx -=1;
- if ((osl_keys->held.down) && (positiony < 242)) positiony += 1;
- if ((osl_keys->held.up) && (positiony > 0)) positiony -= 1;
- // Rotation
- if (osl_keys->held.L) panzer->angle -= 2;
- if (osl_keys->held.R) panzer->angle += 2;
- int sperre = 0;
- if (osl_keys->held.cross && sperre == 0) {
- panzer->angle -= 90;
- sperre = 1;
- }
- if (!osl_keys->held.cross) sperre = 0;
- }
- int main (int argc, char* argv[])
- {
- oslInit(0);
- oslInitGfx(OSL_PF_8888, 1);
- oslInitConsole();
- panzer = oslLoadImageFile("tank.png", OSL_IN_VRAM, OSL_PF_5551);
- background = oslLoadImageFile("bg.png", OSL_IN_VRAM, OSL_PF_5551);
- if (!background) oslDebug("konnte bg.png nicht laden");
- if (!panzer) oslDebug("konnte tank.png nicht laden");
- panzer->centerX = panzer->sizeX / 2;
- panzer->centerY = panzer->sizeY / 2;
- while(!osl_quit)
- {
- ReadKeys();
- oslStartDrawing();
- oslClearScreen(RGB(0,0,0));
- oslDrawImage(background);
- oslDrawImageXY(panzer, positionx, positiony);
- oslEndDrawing();
- oslSyncFrame();
- }
- oslEndGfx();
- oslQuit();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement