Advertisement
Guest User

Untitled

a guest
Feb 20th, 2011
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.26 KB | None | 0 0
  1. // Tank War Beta v0.1
  2. // Created by Lars Knaup
  3. // on 19.02.2011
  4. // sprites by Timo Keim
  5.  
  6. #include <oslib/oslib.h>
  7.  
  8. #define HSIZE 480
  9. #define VSIZE 272
  10.  
  11. PSP_MODULE_INFO("TankWar", 0, 1, 1);
  12. PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
  13.  
  14. OSL_IMAGE* tank;
  15. OSL_IMAGE* bg;
  16.  
  17. int positionx = HSIZE / 2;
  18. int positiony = VSIZE / 2;
  19.  
  20.  
  21. // Funktion: ReadKeys
  22. // Aufgabe: Reagieren auf Tasten
  23. // X: Drehen um 90° gegen den Uhrzeigersinn
  24. // Analog Stick: Fahren
  25. // R: Schießen
  26. void ReadKeys()
  27. {  
  28.     oslReadKeys();
  29.     if ((osl_keys->held.right) && (positionx < 374)) positionx +=1;
  30.     if ((osl_keys->held.left) && (positionx > 0)) positionx -=1;
  31.     if ((osl_keys->held.up) && (positiony < 222)) positiony += 1;
  32.     if ((osl_keys->held.down) && (positiony > 0)) positiony -= 1;
  33. }
  34.  
  35.  
  36. int main (int argc, char* argv[])
  37. {
  38.     oslInit(0);
  39.     oslInitGfx(OSL_PF_8888, 1);
  40.     oslInitConsole();
  41.     tank = oslLoadImageFile("tank.png", OSL_IN_VRAM, OSL_PF_5551);
  42.     bg = oslLoadImageFile("bg.png", OSL_IN_VRAM, OSL_PF_5551);
  43.  
  44.     while(!osl_quit)
  45.     {
  46.         ReadKeys();
  47.         oslStartDrawing();
  48.         oslClearScreen(RGB(0,0,0));
  49.        
  50.         oslDrawImage(bg);      
  51.         oslDrawImageXY(tank, positionx, positiony);
  52.        
  53.         oslEndDrawing();
  54.         oslSyncFrame();
  55.     }
  56.    
  57.     oslEndGfx();
  58.     oslQuit();
  59.    
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement