Advertisement
Guest User

Untitled

a guest
Feb 19th, 2011
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.17 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.  
  16. int speedx;
  17. int speedy;
  18. int positionx = HSIZE / 2;
  19. int positiony = VSIZE / 2;
  20.  
  21.  
  22. // Funktion: ReadKeys
  23. // Aufgabe: Reagieren auf Tasten
  24. // X: Drehen um 90° gegen den Uhrzeigersinn
  25. // Analog Stick: Fahren
  26. // R: Schießen
  27. void ReadKeys()
  28. {
  29.     if ((osl_keys->held.right) || (osl_keys->held.left)) {
  30.         speedx++;
  31.         if (speedx = 10)
  32.             speedx = 0;
  33.    
  34.     if ((osl_keys->held.right) && (positionx < 374)) positionx +=1;
  35.     if ((osl_keys->held.left) && (positionx > 0)) positionx -=1;
  36.     }
  37. }
  38.  
  39.  
  40. int main (int argc, char* argv[])
  41. {
  42.     oslInit(0);
  43.     oslInitGfx(OSL_PF_8888, 1);
  44.     oslInitConsole();
  45.     tank = oslLoadImageFile("tank.png", OSL_IN_VRAM, OSL_PF_5551);
  46.  
  47.     while(!osl_quit)
  48.     {
  49.         ReadKeys();
  50.         oslStartDrawing();
  51.         oslClearScreen(RGB(231,192,114));
  52.        
  53.         oslDrawImageXY(tank, positionx, positiony);
  54.        
  55.         oslEndDrawing();
  56.         oslSyncFrame();
  57.     }
  58.    
  59.     oslEndGfx();
  60.     oslQuit();
  61.    
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement