Exemple #1
0
int main(void){
  
  space = space_init(SCREEN_W, SCREEN_H);

  SDL_Event evt; 

  if (SDL_Init(SDL_INIT_VIDEO) != 0) {
    return -1;
  }

  screen = SDL_SetVideoMode(
    SCREEN_W, 
    SCREEN_H, 
    24, SDL_HWSURFACE | SDL_DOUBLEBUF);

  if (screen == NULL) {
    return -1;
  }

  while(1) {
    while(SDL_PollEvent(&evt)) {
      if(evt.type == SDL_QUIT) {
        goto finish;
      }
      if (evt.type == SDL_KEYUP && evt.key.keysym.sym == SDLK_ESCAPE) {
        goto finish;
      }

      if (evt.type == SDL_MOUSEMOTION    ) space_mouse_move(space, evt.motion.x, evt.motion.y);
      if (evt.type == SDL_MOUSEBUTTONDOWN) space_mouse_down(space);
      if (evt.type == SDL_MOUSEBUTTONUP  ) space_mouse_up  (space);
    }


    SDL_LockSurface(screen);
    SDL_FillRect(screen, NULL, 0x000080); 
    space_update(space, 0.02);

    DrawImpl(space);

    SDL_FreeSurface(screen);
    SDL_Flip(screen);
  }
  
finish:
  
  space_destroy(space);  
  SDL_FreeSurface(screen);
  SDL_Quit();

  return 0;
}
Exemple #2
0
void GameEngine::Draw()
{
  // Set the draw colour for screen clearing.
  _graphicsObject->SetClearColour(1.0f, 1.0f, 1.0f, 1.0f);

  // Clear the renderer with the current draw colour.
  _graphicsObject->ClearScreen();

  DrawImpl(_graphicsObject, _engineTimer.GetDeltaTime());

  // Present what is in our renderer to our window.
  _graphicsObject->Present();
}
Exemple #3
0
void Draw( const Texture &tex, const Rect &texRect, const Rect &destRect, Color color /*= Color::make_white()*/ )
{
  DrawImpl( tex, destRect, Texture::RectMatrixStrat(texRect), color );  
}
Exemple #4
0
void Draw( const Texture &tex, const Rect &rect, int curFrame /*= 0*/, Color color /*= Color::make_white()*/ )
{
  DrawImpl( tex, rect, Texture::FrameMatrixStrat(curFrame), color );
}