Beispiel #1
0
/******************************************************************************
 * Public functions
 *****************************************************************************/
BOOL
render_init (HWND hWnd, LPCTSTR szBmpFile)
{
    debug_printf ("Render_init looking for skin: %s\n", szBmpFile);

    memset (&m_current_skin, 0, sizeof(SKINDATA));
    render_set_default (&m_current_skin);

    /* Look for requested skin */
    if (!load_skindata_from_file (szBmpFile, &m_current_skin)) {
	/* If requested skin not found, look for default skin(s) */
	if (!load_skindata_from_file ("srskin.zip", &m_current_skin)) {
	    if (!load_skindata_from_file ("srskin.bmp", &m_current_skin)) {
		return FALSE;
	    }
	}
    }

    m_tempdc.hdc = NULL;
    m_tempdc.bm = NULL;

    /* Set a timer for mouseovers */
    SetTimer (hWnd, TIMER_ID, 100, (TIMERPROC)on_timer);
    m_hwnd = hWnd;

    render_set_background (m_current_skin.rgn_points, m_current_skin.rgn_npoints);

    return TRUE;
}
Beispiel #2
0
BOOL
render_change_skin (LPCTSTR szBmpFile)
{
    skindata_close (&m_current_skin);
    if (!load_skindata_from_file (szBmpFile, &m_current_skin))
	return FALSE;

    render_set_background (m_current_skin.rgn_points, m_current_skin.rgn_npoints);
    return TRUE;
}
Beispiel #3
0
int main_mainmenu()
{
	SDL_Event e;

	SDL_ShowCursor(SDL_ENABLE);

	g_current_level = level_load("mainmenuconfig");
	render_set_background(g_current_level->background->image);

	player_initialize_list();

	ui_initialize_mainmenu(rtn_renderer());

	do
	{
		render_update(0);
		render_clear();
		while(SDL_PollEvent(&e))
		{
			if(e.type == SDL_KEYDOWN)
			{
				if(e.type == SDL_QUIT)
					exit(0);
				if(e.key.keysym.sym == SDLK_ESCAPE)
				{
					currentstate = EXIT;
					exit(0);
				}
			}
			if(e.type == SDL_MOUSEBUTTONDOWN)
			{
				if(e.button.button == SDL_BUTTON_LEFT)
				{
					click = 1;
				}
			}
			if(e.type == SDL_MOUSEBUTTONUP)
			{
				if(e.button.button == SDL_BUTTON_LEFT)
				{
					click = 0;
				}
			}
			
			if(playclicked == 1)
			{
				slog("Changed to Deathmatch");
				currentstate = DEATHMATCH;
			}
			else if(editorclicked == 1)
			{
				slog("Changed to LevelEditor");
				currentstate = LEVELEDITOR;
			}
			else if(quitclicked == 1)
			{
				exit(0);
			}
		}
	} while(currentstate == MAINMENU);
}
Beispiel #4
0
int main_deathmatch()
{
	SDL_Event e;

	SDL_ShowCursor(SDL_DISABLE);

	entity_initialize_list(1024);
	tank_initialize_list(15);

	g_current_level = level_load("leveloneconfig");
	render_set_background(g_current_level->background->image);

	g_music = audio_load_music("sounds/music/backgroundmusic.wav");
	g_sound = audio_load_sound("sounds/digital/digital.wav");
	if(g_music->file.music != NULL)
	{
		slog("Playing Music");
		//audio_play_music(g_music->file.music);
	}
	else
		slog("Could not load music file");

	player = player_spawn("Player", PLAYER);
	v2d_set(player->tank->tracks->body->position, SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
	v2d_set(player->tank->turret->body->position, SCREEN_WIDTH/2, SCREEN_HEIGHT/2);

	g_now = SDL_GetTicks();

	ui_initialize_deathmatch(rtn_renderer());

	do
	{
		//calculate deltatime
		g_last = g_now;
		g_now = SDL_GetTicks();
		g_deltatime = g_now - g_last;

		render_update(1);
		render_clear();
		entity_all_think();
		entity_all_update();
		player_move(player);
		while(SDL_PollEvent(&e))
		{
			if(e.type == SDL_KEYDOWN)
			{
				if(e.type == SDL_QUIT)
					SDL_Quit();
				if(e.key.keysym.sym == SDLK_w)
					player->keysHeld.W = 1;
				if(e.key.keysym.sym == SDLK_s)
					player->keysHeld.S = 1;
				if(e.key.keysym.sym == SDLK_a)
					player->keysHeld.A = 1;
				if(e.key.keysym.sym == SDLK_d)
					player->keysHeld.D = 1;
				if(e.key.keysym.sym == SDLK_e)
				{
					tank_weapon_change(player->tank);
					slog("Current weapon: %s", player->tank->currentweapon->name);
				}
				if(e.key.keysym.sym == SDLK_p)
				{
					audio_play_sound(g_sound->file.sound);
				}
				if(e.key.keysym.sym == SDLK_f)
				{
					Entity *sonar;
					sonar = sonar_new(sonar = entity_new(SONAR, NULL), 3.0, player->tank);
				}
				if(e.key.keysym.sym == SDLK_g)
				{
					tank_weapon_fire(player->tank);
				}
				if(e.key.keysym.sym == SDLK_h)
					player->tank->health -= 5;
				if(e.key.keysym.sym == SDLK_j)
					player->tank->armour -= 5;
				if(e.key.keysym.sym == SDLK_SPACE)
				{
					if(player->tank->is_hidden)
						player->tank->is_hidden = 0;
					else
						player->tank->is_hidden = 1;

					tank_sprite_change(player->tank);
				}
				if(e.key.keysym.sym == SDLK_ESCAPE)
				{
					playclicked = 0;
					entity_close_list();
					tank_close_list();
					player_close_list();
					currentstate = MAINMENU;
				}
			}
			if(e.type == SDL_KEYUP)
			{
				if(e.key.keysym.sym == SDLK_w)
					player->keysHeld.W = 0;
				if(e.key.keysym.sym == SDLK_s)
					player->keysHeld.S = 0;
				if(e.key.keysym.sym == SDLK_a)
					player->keysHeld.A = 0;
				if(e.key.keysym.sym == SDLK_d)
					player->keysHeld.D = 0;
			}
		}
		if(g_deltatime < 32)
			SDL_Delay(32-g_deltatime);
	} while(currentstate == DEATHMATCH);

	return 0;
}