/** * Draw the current frame */ static void ps_draw() { GFraMe_event_draw_begin(); #ifdef DEBUG _drwCalls++; #endif map_draw(m); rg_drawBullets(); rg_drawObjects(); rg_drawMobs(); if (gv_nIsZero(SWITCH_MAP)) transition_draw(); ui_draw(); player_draw(p2); player_draw(p1); if (gv_isZero(SWITCH_MAP)) signal_draw(); #ifdef QT_DEBUG_DRAW if (GFraMe_keys.f1 || (GFraMe_controller_max > 0 && GFraMe_controllers[0].l2)) qt_drawRootDebug(); #endif if (_ps_pause) { ps_drawPause(); } if (_ps_isSpeedrun) timer_draw(); if (_ps_text) { textWnd_draw(); } GFraMe_event_draw_end(); }
/** * Draw the state * * @param pGame The game's context * @return GFMRV_OK, GFMRV_ARGUMENTS_BAD, ... */ gfmRV intro_draw_begin(gameCtx *pGame) { gfmRV rv; introCtx *pIntro; // Sanitize arguments ASSERT(pGame, GFMRV_ARGUMENTS_BAD); ASSERT(pGame->pState, GFMRV_ARGUMENTS_BAD); // Get the current state pIntro = (introCtx*)(pGame->pState); // TODO Draw everything rv = gfmTilemap_draw(pGame->common.pTMap, pGame->pCtx); ASSERT_NR(rv == GFMRV_OK); rv = player_draw(pIntro->pPl, pGame); ASSERT_NR(rv == GFMRV_OK); rv = doc_draw(pIntro->pDoc, pGame); ASSERT_NR(rv == GFMRV_OK); rv = gfmTilemap_draw(pIntro->pMachineFx, pGame->pCtx); ASSERT_NR(rv == GFMRV_OK); rv = gfmText_draw(pGame->common.pText, pGame->pCtx); ASSERT_NR(rv == GFMRV_OK); #if 0 rv = gfmQuadtree_drawBounds(pGame->common.pQt, pGame->pCtx, 0/*colors*/); ASSERT_NR(rv == GFMRV_OK); #endif rv = GFMRV_OK; __ret: return rv; }
/** * Draw the state * * @param pGame The game's context * @return GFMRV_OK, GFMRV_ARGUMENTS_BAD, ... */ gfmRV intro_draw_flash(gameCtx *pGame) { gfmRV rv; introCtx *pIntro; // Sanitize arguments ASSERT(pGame, GFMRV_ARGUMENTS_BAD); ASSERT(pGame->pState, GFMRV_ARGUMENTS_BAD); // Get the current state pIntro = (introCtx*)(pGame->pState); // TODO Draw everything rv = gfmTilemap_draw(pGame->common.pTMap, pGame->pCtx); ASSERT_NR(rv == GFMRV_OK); rv = player_draw(pIntro->pPl, pGame); ASSERT_NR(rv == GFMRV_OK); rv = doc_draw(pIntro->pDoc, pGame); ASSERT_NR(rv == GFMRV_OK); rv = gfmTilemap_draw(pIntro->pFlashFx, pGame->pCtx); ASSERT_NR(rv == GFMRV_OK); rv = GFMRV_OK; __ret: return rv; }
/** * Draw the state * * @param pGame The game's context * @return GFMRV_OK, GFMRV_ARGUMENTS_BAD, ... */ gfmRV intro_draw_game(gameCtx *pGame) { gfmRV rv; introCtx *pIntro; // Sanitize arguments ASSERT(pGame, GFMRV_ARGUMENTS_BAD); ASSERT(pGame->pState, GFMRV_ARGUMENTS_BAD); // Get the current state pIntro = (introCtx*)(pGame->pState); rv = gfmTilemap_draw(pGame->common.pTMap, pGame->pCtx); ASSERT_NR(rv == GFMRV_OK); rv = player_draw(pIntro->pPl, pGame); ASSERT_NR(rv == GFMRV_OK); rv = doc_draw(pIntro->pDoc, pGame); ASSERT_NR(rv == GFMRV_OK); rv = gfmSprite_draw(pIntro->pBullet1, pGame->pCtx); ASSERT_NR(rv == GFMRV_OK); rv = gfmSprite_draw(pIntro->pBullet2, pGame->pCtx); ASSERT_NR(rv == GFMRV_OK); // TODO Draw the bullets and the enemies... rv = GFMRV_OK; __ret: return rv; }
void scene_render_game(Uint32 delta) { background_draw(3, delta); world_draw(delta); player_draw(delta); enemy_draw(); item_draw(); bullet_draw(); player_life_draw(); world_life_draw(); }
int draw_shit(struct Game* game) { // draw the world first world_draw(game->world); // draw the player last player_draw(game->player); // draw any windows that may cover the player (e.g. menus) }
void game_tick(Game *game) { int ch = 0, move_result = BALL_MOVED; long elapsed = elapsed_since(&game->start_time); static long last_event = 0; if ((elapsed - last_event) >= (BALL_DELAY * MICROSECONDS_PER_SECOND)) { move_result = ball_move(game->ball, game->field, game->player); if (move_result == BALL_SCORE) { game->player->score += 1; } else if (move_result == BALL_MISS) { game->player->score = 0; ball_reset(game->ball, game->field); } last_event = elapsed; } if ((ch = getch()) != ERR) { if (ch == MOVE_UP) { player_move(game->field, game->player, -1); } if (ch == MOVE_DOWN) { player_move(game->field, game->player, 1); } } // field_refresh(game->field); field_redraw(game->field); wclear(game->field->game); field_draw_score(game->field, game->player); wrefresh(game->field->score); player_draw(game->player, game->field); ball_draw(game->ball, game->field); wrefresh(game->field->game); }
//ZZZ TODO Seperate this all out void game_controller_draw_top(GameController self) { //Left Eye sf2d_start_frame(GFX_TOP, GFX_LEFT); //Left for Standard Vision sf2d_draw_rectangle(0, 0, 400, 240, RGBA8(0xFF, 0xFF, 0x89, 0xFF)); //Background if (self->enemy->health > 0) enemy_draw(self->enemy); /*ZZZ TESTING ZZZ */ //bullet_draw(self->bullet); //bullet_draw(self->bullet_storage->bullet_array[0]); //bullet_draw(self->bullet_storage->bullet_array[self->bullet_storage->bullet_limit-1]); bullet_storage_draw_all(self->bullet_storage); player_draw(self->player); //Draw player ontop of all game objects. //Pause interface if (self->is_paused) sf2d_draw_rectangle(0, 0, 400, 240, RGBA8(0x7A, 0x7A, 0x7A, 0xCC)); sf2d_end_frame(); }
/*notice the default arguments for main. SDL expects main to look like that, so don't change it*/ int main(int argc, char *argv[]) { SDL_Surface *temp = NULL; int done; int tx = 0,ty = 0; int i; const Uint8 *keys; char imagepath[512]; SDL_Rect srcRect={0,0,SCREEN_WIDTH,SCREEN_HEIGHT}; SDL_Event e; last_time = current_time = SDL_GetTicks(); Init_All(); slog("Finished Init All()"); done = 0; do { //render or draw functions go here //draw functions should go in order from background first to player draw calls last ResetBuffer(); SDL_RenderClear(__gt_graphics_renderer);//clear screen tile_render(); player_draw(); DrawMouse2(); /*monster_spawn(Monster::grue); monster_spawn(Monster::spider01); monster_spawn(Monster::mino); monster_spawn(Monster::orc); support_spawn(Support::sara); support_spawn(Support::healer); support_spawn(Support::archer); */ entity_update_all(); entity_think_all(); entity_check_collision_all(); particle_em_draw_all(); // struct_update_all(); G_MONSTER_SPAWN_TIMER -= 1; while(SDL_PollEvent(&e) != 0) player_move (&e); NextFrame(); //end SDL_PumpEvents(); keys = SDL_GetKeyboardState(NULL); //taken from lazyfoo //handles generally keyboard inputs while( SDL_PollEvent( &e) != 0){ if(e.type == SDL_QUIT) done = 1; else player_move(&e); } if(keys[SDL_SCANCODE_ESCAPE]) { done = 1; } SDL_RenderPresent(__gt_graphics_renderer); last_time = current_time; current_time = SDL_GetTicks(); delta = current_time - last_time; }while(!done); exit(0); /*technically this will end the program, but the compiler likes all functions that can return a value TO return a value*/ return 0; }
int game_loop(){ unsigned redraw = 0; game_rect t; rect_Zero(&t); sprite_sheet = gamespr_create("ski1.bmp"); animation_init(); init_player(); start_new_game(0); while(!mainloop){ ALLEGRO_EVENT e; ALLEGRO_TIMEOUT timeout; int i; al_init_timeout(&timeout, 0.06); bool late = al_wait_for_event_until(g_queue, &e, &timeout); if(late){ switch(e.type){ case ALLEGRO_EVENT_DISPLAY_CLOSE: mainloop = 1; break; case ALLEGRO_EVENT_KEY_UP: player_poll_kbd_up(&e); break; case ALLEGRO_EVENT_KEY_DOWN: player_poll_kbd_dn(&e); break; case ALLEGRO_EVENT_TIMER: /* main clock updates 1/60ms (60FPS LOCK) */ if(e.timer.source == g_timer){ particle_list = particles_clean(particle_list, 0); particles_update(particle_list); player_update_screen(); player_update(&ski_player, &playfield); for(i = 1; i < MAX_SPRITES; i++){ update_enemy(i); } update_enemy_behavior(gobj_list, &playfield); redraw = 1; } /* update for the chronomenter run every 100ms only) */ if( e.timer.source == timer_chrono){ HUD_UpdateChrono(); DMSG("%d", al_get_timer_count(timer_chrono)); } break; } if( redraw == 1 && al_event_queue_is_empty(g_queue)){ redraw = 0; al_clear_to_color(WHITE_COLOR); particles_draw(NULL, particle_list); player_draw(ski_player.object->position.x, ski_player.object->position.y ); for(i = 1; i < MAX_OBJECTS; i++){ int enemy_type = gobj_list[i].type; draw_enemy(enemy_type, i, 0,0, gobj_list[i].position.x, gobj_list[i].position.y, 32,32); } HUD_create_stats_box(); al_flip_display(); } } } HUD_destroy(); unload_spritesheets(); window_deinit(); particle_list = particles_clean(particle_list, PARTICLES_ALL_CLEAN); return EXIT_SUCCESS; }