Advertisement
Guest User

Untitled

a guest
Feb 24th, 2011
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.75 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* panzer;
  15. OSL_IMAGE* background;
  16.  
  17. int positionx = HSIZE / 2;
  18. int positiony = VSIZE / 2;
  19.  
  20.  
  21.  
  22. // Funktion: ReadKeys
  23. // Aufgabe: Reagieren auf Tasten
  24. // L und R: Rotieren
  25. // Analog Stick: Fahren
  26. // X: Schießen
  27. void ReadKeys()
  28. {  
  29.     oslReadKeys();
  30.    
  31.     // Bewegung
  32.     if ((osl_keys->held.right) && (positionx < 450)) positionx +=1;
  33.     if ((osl_keys->held.left) && (positionx > 0)) positionx -=1;
  34.     if ((osl_keys->held.down) && (positiony < 242)) positiony += 1;
  35.     if ((osl_keys->held.up) && (positiony > 0)) positiony -= 1;
  36.    
  37.     // Rotation
  38.     if (osl_keys->held.L) panzer->angle -= 2;
  39.     if (osl_keys->held.R) panzer->angle += 2;
  40.    
  41.     int sperre = 0;
  42.    
  43.     if (osl_keys->held.cross && sperre == 0) {
  44.         panzer->angle -= 90;
  45.         sperre = 1;
  46.     }  
  47.    
  48. if (!osl_keys->held.cross) sperre = 0;
  49.  
  50. }
  51.  
  52.  
  53. int main (int argc, char* argv[])
  54. {
  55.     oslInit(0);
  56.     oslInitGfx(OSL_PF_8888, 1);
  57.     oslInitConsole();  
  58.    
  59.     panzer = oslLoadImageFile("tank.png", OSL_IN_VRAM, OSL_PF_5551);
  60.     background = oslLoadImageFile("bg.png", OSL_IN_VRAM, OSL_PF_5551);
  61.  
  62.     if (!background) oslDebug("konnte bg.png nicht laden");
  63.     if (!panzer) oslDebug("konnte tank.png nicht laden");
  64.     panzer->centerX = panzer->sizeX / 2;
  65.     panzer->centerY = panzer->sizeY / 2;
  66.  
  67.     while(!osl_quit)
  68.     {
  69.         ReadKeys();
  70.         oslStartDrawing();
  71.         oslClearScreen(RGB(0,0,0));
  72.        
  73.         oslDrawImage(background);      
  74.         oslDrawImageXY(panzer, positionx, positiony);
  75.        
  76.         oslEndDrawing();
  77.         oslSyncFrame();
  78.     }
  79.    
  80.     oslEndGfx();
  81.     oslQuit();
  82.    
  83.     return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement