Beispiel #1
0
void presentHomeScreen(int width, int height) {
    
    //present home screen
    gfx_color(255, 255, 255);
    gfx_changefont("-*-helvetica-bold-r-*-*-*-250-90-90-p-*-iso8859-1");
    gfx_text(width/2-88, 150, "GET READY");
    gfx_text(width/2-5, 50, "0");
    
    //draw spacebar
    gfx_color(255, 255, 255);
    gfx_fill_rectangle(width/2-100, height/2+60, 200, 30);
    gfx_changefont("-*-helvetica-bold-r-*-*-*-120-75-75-p-*-iso8859-1");
    gfx_color(206, 212, 214);
    gfx_text(width/2-20, height/2+80, "SPACE");
    gfx_rectangle(width/2-100, height/2+60, 200, 30);
    
    //draw tap notice
    gfx_color(206, 212, 214);
    gfx_fill_rectangle(width/2-13, height/2+120, 26, 26);
    gfx_color(250, 0, 46);
    gfx_fill_rectangle(width/2-12, height/2+121, 24, 24);
    gfx_color(255, 255, 255);
    gfx_changefont("-*-helvetica-bold-r-*-*-*-100-60-60-p-*-iso8859-1");
    gfx_text(width/2-8, height/2+136, "TAP");
    gfx_fill_rectangle(width/2-1, height/2+98, 2, 15);
    
    //draw background
    drawBackground(width, height);
    
}
Beispiel #2
0
void HUD::render_voting()
{
	if(!gameclient.voting->is_voting())
		return;
	
	gfx_texture_set(-1);
	gfx_quads_begin();
	gfx_setcolor(0,0,0,0.40f);
	draw_round_rect(-10, 60-2, 100+10+4+5, 28, 5.0f);
	gfx_quads_end();

	gfx_text_color(1,1,1,1);

	char buf[512];
	gfx_text(0x0, 5, 60, 6, gameclient.voting->vote_description(), -1);

	str_format(buf, sizeof(buf), "%ds left", gameclient.voting->seconds_left());
	float tw = gfx_text_width(0x0, 6, buf, -1);
	gfx_text(0x0, 5+100-tw, 60, 6, buf, -1);
	

	RECT base = {5, 70, 100, 4};
	gameclient.voting->render_bars(base, false);
	
	const char *yes_key = gameclient.binds->get_key("vote yes");
	const char *no_key = gameclient.binds->get_key("vote no");
	str_format(buf, sizeof(buf), "%s - Vote Yes", yes_key);
	base.y += base.h+1;
	ui_do_label(&base, buf, 6.0f, -1);

	str_format(buf, sizeof(buf), "Vote No - %s", no_key);
	ui_do_label(&base, buf, 6.0f, 1);
}
Beispiel #3
0
void NAMEPLATES::render_nameplate(
	const NETOBJ_CHARACTER *prev_char,
	const NETOBJ_CHARACTER *player_char,
	const NETOBJ_PLAYER_INFO *player_info
	)
{
	float intratick = client_intratick();
	
	vec2 position = mix(vec2(prev_char->x, prev_char->y), vec2(player_char->x, player_char->y), intratick);
	
	// render name plate
	if(!player_info->local)
	{
		//gfx_text_color
		float a = 1;
		if(config.cl_nameplates_always == 0)
			a = clamp(1-powf(distance(gameclient.controls->target_pos, position)/200.0f,16.0f), 0.0f, 1.0f);
			
		const char *name = gameclient.clients[player_info->cid].name;
		float tw = gfx_text_width(0, 28.0f, name, -1);
		gfx_text_color(1,1,1,a);
		gfx_text(0, position.x-tw/2.0f, position.y-60, 28.0f, name, -1);
		
		if(config.debug) // render client id when in debug aswell
		{
			char buf[128];
			str_format(buf, sizeof(buf),"%d", player_info->cid);
			gfx_text(0, position.x, position.y-90, 28.0f, buf, -1);
		}

		gfx_text_color(1,1,1,1);
	}
}
Beispiel #4
0
void HUD::render_spectate()
{
	if(gameclient.freeview)
		gfx_text(0, 4*gfx_screenaspect(), 4, 8, "Freeview", -1);
	else
	{
		char buf[96];
		str_format(buf, sizeof(buf), "Following: %s", gameclient.clients[gameclient.spectate_cid].name);
		gfx_text(0, 4*gfx_screenaspect(), 4, 8, buf, -1);
	}
}
Beispiel #5
0
void yAxis(int x, int y) {
	int i;
	gfx_line(x / 2, 0, x / 2, y);	
	for(i = 1; i <= 21; i++) {
		gfx_line((x / 2) - 10, i * (y / 22.), (x / 2) + 10, i * (y / 22.));
		gfx_text((x / 2) - 15, (22 - i) * (y / 22.), num2str(i - 11));
	}
}
Beispiel #6
0
void xAxis(int x, int y) {
	int i;
	gfx_line(0, y / 2, x, y / 2);
	for(i = 1; i <=21; i++) {
		gfx_line(i * (x / 22.), (y / 2) - 10, i * (x / 22.), (y / 2) + 10);
		gfx_text(i * (x / 22.), (y / 2) + 15, num2str(i - 11));
	}
}
Beispiel #7
0
void HUD::render_connectionwarning()
{
	if(client_connection_problems())
	{
		const char *text = "Connection Problems...";
		float w = gfx_text_width(0, 24, text, -1);
		gfx_text(0, 150*gfx_screenaspect()-w/2, 50, 24, text, -1);
	}
}
Beispiel #8
0
void HUD::render_fps()
{
	if(config.cl_showfps && !config.cl_clear_all && !config.cl_clear_hud)
	{
		char buf[512];
		str_format(buf, sizeof(buf), "%d", (int)(1.0f/client_frametime()));
		gfx_text(0, width-10-gfx_text_width(0,12,buf,-1), 5, 12, buf, -1);
	}
}
Beispiel #9
0
void yAxis(){
	int i,j;
	gfx_color(0,0,255);
	gfx_line(250,0,250,500);
	for(i=0,j=-10;i<=500,j<=10;i+=25,j++){
		gfx_line(240,i,260,i);
		gfx_color(255,255,255);
		gfx_text(225,i, num2str(j));
	}
}
Beispiel #10
0
void xAxis(){
	int i,j;
	gfx_color(0,0,255);
	gfx_line(0,250,500,250);
	for(i=0,j=-10;i <= 500,j<=10; i+=25,j++){
		gfx_line(i,240,i,260);
		gfx_color(255,255,255);
		gfx_text(i,275, num2str(j));
	}
}
Beispiel #11
0
void printScore(int score, int width){

    //Prints the score at the top of the screen
    gfx_color(255, 255, 255);
    gfx_changefont("-*-helvetica-bold-r-*-*-*-250-90-90-p-*-iso8859-1");
    char str[10];
    sprintf(str, "%d", score);
    gfx_text(width/2-5, 50, str);

}
Beispiel #12
0
void BROADCAST::on_render()
{
	gfx_mapscreen(0, 0, 300*gfx_screenaspect(), 300);
		
	if(time_get() < broadcast_time)
	{
		float w = gfx_text_width(0, 14, broadcast_text, -1);
		gfx_text(0, 150*gfx_screenaspect()-w/2, 35, 14, broadcast_text, -1);
	}
}
void startGame(int xSize, int ySize)
{
	char c;
	char *intro = "Welcome to Asteroid! Press 'p' to play!";

	gfx_text((xSize/2)-(strlen(intro)/2)*5, ySize/2, intro);
	c = gfx_wait();
	while(c != 'p'){
		c = gfx_wait();
	}
}
Beispiel #14
0
void BROADCAST::on_render()
{
	if(!config.cl_render_broadcast || config.cl_clear_all)
		return;
	gfx_mapscreen(0, 0, 300*gfx_screenaspect(), 300);
		
	if(time_get() < broadcast_time)
	{
		float w = gfx_text_width(0, 14, broadcast_text, -1);
		gfx_text(0, 150*gfx_screenaspect()-w/2, 35, 14, broadcast_text, -1);
	}
}
Beispiel #15
0
void SCOREBOARD::render_goals(float x, float y, float w)
{
	float h = 50.0f;

	gfx_blend_normal();
	gfx_texture_set(-1);
	gfx_quads_begin();
	gfx_setcolor(0,0,0,0.5f);
	draw_round_rect(x-10.f, y-10.f, w, h, 10.0f);
	gfx_quads_end();

	// render goals
	//y = ystart+h-54;
	float tw = 0.0f;
	if(gameclient.snap.gameobj && gameclient.snap.gameobj->score_limit)
	{
		char buf[64];
		str_format(buf, sizeof(buf), "Score Limit: %d", gameclient.snap.gameobj->score_limit);
		gfx_text(0, x+20.0f, y, 22.0f, buf, -1);
		tw += gfx_text_width(0, 22.0f, buf, -1);
	}
	if(gameclient.snap.gameobj && gameclient.snap.gameobj->time_limit)
	{
		char buf[64];
		str_format(buf, sizeof(buf), "Time Limit: %d min", gameclient.snap.gameobj->time_limit);
		gfx_text(0, x+220.0f, y, 22.0f, buf, -1);
		tw += gfx_text_width(0, 22.0f, buf, -1);
	}
	if(gameclient.snap.gameobj && gameclient.snap.gameobj->round_num && gameclient.snap.gameobj->round_current)
	{
		char buf[64];
		str_format(buf, sizeof(buf), "Round %d/%d", gameclient.snap.gameobj->round_current, gameclient.snap.gameobj->round_num);
		gfx_text(0, x+450.0f, y, 22.0f, buf, -1);
		
	/*[48c3fd4c][game/scoreboard]: timelimit x:219.428558
	[48c3fd4c][game/scoreboard]: round x:453.142822*/
	}
}
Beispiel #16
0
char win(void)
{
  gfx_clear_color(0,0,255); //blue background
  gfx_clear();
  gfx_color(255,255,255); //white letters

  //You
  gfx_fill_rectangle(370,160,40,60);
  gfx_fill_rectangle(470,160,40,60);
  gfx_fill_rectangle(390,220,100,20);
  gfx_fill_rectangle(410,240,60,60);
 
  //yOu
  gfx_fill_rectangle(530,180,40,100);
  gfx_fill_rectangle(630,180,40,100);
  gfx_fill_rectangle(550,160,100,20);
  gfx_fill_rectangle(550,280,100,20);

  //yoU
  gfx_fill_rectangle(690,160,40,120);
  gfx_fill_rectangle(790,160,40,120);
  gfx_fill_rectangle(710,280,100,20);

  //Won
  gfx_fill_rectangle(370,350,40,140);
  gfx_fill_rectangle(470,350,40,140);
  gfx_fill_rectangle(410,430,20,40);
  gfx_fill_rectangle(430,410,20,40);
  gfx_fill_rectangle(450,430,20,40);

  //wOn
  gfx_fill_rectangle(530,370,40,100);
  gfx_fill_rectangle(630,370,40,100);
  gfx_fill_rectangle(550,350,100,20);
  gfx_fill_rectangle(550,470,100,20);

  //woN
  gfx_fill_rectangle(690,350,40,140);
  gfx_fill_rectangle(790,350,40,140);
  gfx_fill_rectangle(730,370,20,40);
  gfx_fill_rectangle(750,390,20,40);
  gfx_fill_rectangle(770,410,20,40);

  gfx_text(450,520,"Press any key to play Frogger. Press \'q\' to quit.");

  return gfx_wait();
}
Beispiel #17
0
void HUD::render_speed()
{
	if(!config.tc_speedmeter)
		return;

	// We calculate the speed instead of getting it from character.velocity cause it's buggy when
	// walking in front of a wall or when using the ninja sword
	static float speed;
	static vec2 oldpos;
	static const int SMOOTH_TABLE_SIZE = 16;
	static const int ACCEL_THRESHOLD = 25;
	static float smooth_table[SMOOTH_TABLE_SIZE];
	static int smooth_index = 0;

	smooth_table[smooth_index] = distance(gameclient.local_character_pos, oldpos)/client_frametime();
	if(demorec_isplaying()) {
		float mult = client_demoplayer_getinfo()->speed;
		smooth_table[smooth_index] /= mult;
	}
	smooth_index = (smooth_index + 1) % SMOOTH_TABLE_SIZE;
	oldpos = gameclient.local_character_pos;
	speed = 0;
	for(int i=0; i<SMOOTH_TABLE_SIZE; i++)
		speed += smooth_table[i];
	speed /= SMOOTH_TABLE_SIZE;

	int t = (gameclient.snap.gameobj->flags & GAMEFLAG_TEAMS)? -1 : 1;
	int last_index = smooth_index - 1;
	if(last_index < 0)
		last_index = SMOOTH_TABLE_SIZE - 1;

	gfx_blend_normal();
	gfx_texture_set(-1);
	gfx_quads_begin();
	if(config.tc_speedmeter_accel && speed - smooth_table[last_index] > ACCEL_THRESHOLD)
		gfx_setcolor(0.6f, 0.1f, 0.1f, 0.25f);
	else if(config.tc_speedmeter_accel && speed - smooth_table[last_index] < -ACCEL_THRESHOLD)
		gfx_setcolor(0.1f, 0.6f, 0.1f, 0.25f);
	else
		gfx_setcolor(0.1, 0.1, 0.1, 0.25);
	draw_round_rect(width-40, 245+t*20, 50, 18, 5.0f);
	gfx_quads_end();

	char buf[16];
	str_format(buf, sizeof(buf), "%.0f", speed);
	gfx_text(0, width-5-gfx_text_width(0,12,buf,-1), 246+t*20, 12, buf, -1);
}
Beispiel #18
0
void HUD::render_teambalancewarning()
{
	// render prompt about team-balance
	bool flash = time_get()/(time_freq()/2)%2 == 0;
	if (gameclient.snap.gameobj && (gameclient.snap.gameobj->flags&GAMEFLAG_TEAMS) != 0)
	{	
		if (config.cl_warning_teambalance && !config.cl_clear_all && abs(gameclient.snap.team_size[0]-gameclient.snap.team_size[1]) >= 2)
		{
			const char *text = "Please balance teams!";
			if(flash)
				gfx_text_color(1,1,0.5f,1);
			else
				gfx_text_color(0.7f,0.7f,0.2f,1.0f);
			gfx_text(0x0, 5, 50, 6, text, -1);
			gfx_text_color(1,1,1,1);
		}
	}
}
Beispiel #19
0
void SCOREBOARD::render_spectators(float x, float y, float w)
{
	char buffer[1024*4];
	int count = 0;
	float h = 120.0f;
	
	str_copy(buffer, "Spectators: ", sizeof(buffer));

	gfx_blend_normal();
	gfx_texture_set(-1);
	gfx_quads_begin();
	gfx_setcolor(0,0,0,0.5f);
	draw_round_rect(x-10.f, y-10.f, w, h, 10.0f);
	gfx_quads_end();
	
	for(int i = 0; i < snap_num_items(SNAP_CURRENT); i++)
	{
		SNAP_ITEM item;
		const void *data = snap_get_item(SNAP_CURRENT, i, &item);

		if(item.type == NETOBJTYPE_PLAYER_INFO)
		{
			const NETOBJ_PLAYER_INFO *info = (const NETOBJ_PLAYER_INFO *)data;
			if(info->team == -1)
			{
				if(count)
					strcat(buffer, ", ");
				if(config.cl_scoreboard_client_id)
				{
					char buf[128];
					str_format(buf, sizeof(buf), "%d | %s", info->cid, gameclient.clients[info->cid].name);
					str_append(buffer, buf, sizeof(buffer));
				}
				else
				{
					strcat(buffer, gameclient.clients[info->cid].name);
				}
				count++;
			}
		}
	}
	
	gfx_text(0, x+10, y, 32, buffer, (int)w-20);
}
Beispiel #20
0
void DEBUGHUD::render_netcorrections()
{
	if(!config.debug || !gameclient.snap.local_character || !gameclient.snap.local_prev_character)
		return;

	gfx_mapscreen(0, 0, 300*gfx_screenaspect(), 300);
	
	/*float speed = distance(vec2(netobjects.local_prev_character->x, netobjects.local_prev_character->y),
		vec2(netobjects.local_character->x, netobjects.local_character->y));*/

	float velspeed = length(vec2(gameclient.snap.local_character->vx/256.0f, gameclient.snap.local_character->vy/256.0f))*50;
	
	float ramp = velocity_ramp(velspeed, gameclient.tuning.velramp_start, gameclient.tuning.velramp_range, gameclient.tuning.velramp_curvature);
	
	char buf[512];
	str_format(buf, sizeof(buf), "%.0f\n%.0f\n%.2f\n%d %s\n%d %d",
		velspeed, velspeed*ramp, ramp,
		netobj_num_corrections(), netobj_corrected_on(),
		gameclient.snap.local_character->x,
		gameclient.snap.local_character->y
	);
	gfx_text(0, 150, 50, 12, buf, -1);
}
Beispiel #21
0
void MOTD::on_render()
{
	if(!is_active())
		return;
		
	float width = 400*3.0f*gfx_screenaspect();
	float height = 400*3.0f;

	gfx_mapscreen(0, 0, width, height);
	
	float h = 800.0f;
	float w = 650.0f;
	float x = width/2 - w/2;
	float y = 150.0f;

	gfx_blend_normal();
	gfx_texture_set(-1);
	gfx_quads_begin();
	gfx_setcolor(0,0,0,0.5f);
	draw_round_rect(x, y, w, h, 40.0f);
	gfx_quads_end();

	gfx_text(0, x+40.0f, y+40.0f, 32.0f, server_motd, (int)(w-80.0f));
}
Beispiel #22
0
void animateMotion(int xtl, int ytl,int boardHeight,int boardWidth,Location *pacman,Location ghosts[],int height,int width, int lives,int state[],int score,int newScore[],int frightenLoop[],int loop){
/* This function is called after pacman is moved, and animates the movement of pacman,
 * and all the ghosts. While the ghosts' new positions are tabulated in moveGhosts, they
 * are not drawn until this function is called after pacman is moved */
  int i,j,loops=2;

  int x=xtl+pacman->x*radius+radius/2;	//first location to draw, will increment 5 times
  int y=ytl+pacman->y*radius+radius/2;

  Location delta;
  delta.x=(pacman->x-pacman->prevX)*radius/loops;
  delta.y=(pacman->y-pacman->prevY)*radius/loops;
/* Currently, pacman only moves one space abruptly, he cannot smoothly move from cell to cell */
  //for(j=1;j<=loops+1;j++){	//this loop allows the pacman movement to be smooth
    gfx_clear();
    if(loop==1){i=3;}
    drawBoard(xtl,ytl,boardHeight,boardWidth,height,width,lives,i,score);
    drawPacman(x,y,pacman->orientation,0);
    //x+=delta.x;
    //y+=delta.y;
    //usleep(10000);
  //}
  for(i=blinky;i<=clyde;i++){
    x=xtl+ghosts[i].x*radius+radius/2;
    y=ytl+ghosts[i].y*radius+radius/2;
    drawGhost(x,y,i,ghosts[i].orientation,state,frightenLoop[i]);
  }
  /* Check if there needs to be a score displayed */
  if(newScore[0]){
        gfx_color(120,120,120);
        gfx_text(xtl+newScore[1]*radius+radius/2,ytl+newScore[2]*radius+radius/2,num2str(newScore[0]));
        newScore[0]=0;
	newScore[1]=0;
	newScore[2]=0;
  }
}
Beispiel #23
0
int main(int argc, char* argv[]){
	unsigned int size;/*Tamanho do triangulo*/
	unsigned int default_size;/*Tamanho padrão do triangulo*/
	unsigned int amount; /*Quantidade de triangulos*/
	int quit; /*Verifica se o programa deve ser encerrado*/
	char* msg; /*Auxiliar para colocar as informaçoes na tela*/
	SDL_Event event; /*guarda um evento ocorrido*/
	
	msg = (char*) malloc(sizeof(char) * 30); /*Aloca memoria para a string auxiliar*/
	if(!msg){/*Verifica se foi alocado*/
		printf("Erro ao alocar memoria.\n");
		exit (0);
	}

	amount = 0;/*Inicializa o contador de triangulos*/
	default_size = 100;/*Define o tamanho padrão do triangulo para caso o usuario não tenha definido*/

	if(argc != 1){/*Verifica se foi passado algum argumento na chamada do programa*/
		if(atoi(argv[1]) != 0){/*Se o argumento for um numero ele sera o tamanho padrão do triangulo*/
			default_size = atoi(argv[1]);
		}
	}
	
	size = default_size;/*Define o tamanho com o tamanho padrão*/
	
	gfx_init("Sierpinski");/*Seta o nome da janela*/
	
	sierpinski((gfx_get_width() / 2) - (size / 2), gfx_get_height() - (int)((size * 1.732050808) / 2), size, &amount);/*Desenha o triangulo com o tamanho incial*/
	sprintf(msg, "Lado: %d     Quantidade: %u", size, amount);
	gfx_text(10, 10, msg);/*Imprime as informacões do triangulo*/
	gfx_text(10, 30, "Atalhos: Zoom(i)n - Zoom(o)ut - (C)lear - (esc)ape");/*Imprime o menu*/
	gfx_paint();
	
	while(!quit){/*Loop principal*/
		while(SDL_PollEvent(&event)){/*Verifica se ocorreu algum evento*/
			switch(event.type){/*Seleciona o tipo de evento*/
				case SDL_QUIT:/*Clique no botão de fechar*/
					quit = 1;/*sair do loop principal*/
					break;
				case SDL_KEYDOWN:/*Tecla pressionada*/
					while(event.key.state == SDL_PRESSED && quit == 0){/*Tecla continua pressionada e não é o ESC*/
						switch (event.key.keysym.sym){/*Seleciona a tecla*/
							case SDLK_i:/*Caso seja 'i' os triangulos aumentam*/
								size += 5;/*Incrementa o tamanho do triangulo*/
								gfx_clear();/*Limpa a tela*/
								amount = 0;/*Zera o contador de triangulos*/
								sierpinski((gfx_get_width() / 2) - (size / 2), gfx_get_height() - (int)((size * 1.732050808) / 2), size, &amount);/*Desenha o triangulo de Sierpinski*/
								sprintf(msg, "Lado: %d     Quantidade: %u", size, amount);
								gfx_text(10, 10, msg);/*Imprime as informacões do triangulo*/
								gfx_text(10, 30, "Atalhos: Zoom(i)n - Zoom(o)ut - (C)lear - (esc)ape");/*Imprime o menu*/
								break;

							case SDLK_o:/*Caso seja 'o' os triangulos diminuem*/
								size -= 5;
								gfx_clear();
								amount = 0;
								sierpinski((gfx_get_width() / 2) - (size / 2), gfx_get_height() - (int)((size * 1.732050808) / 2), size, &amount);
								sprintf(msg, "Lado: %d     Quantidade: %u", size, amount);
								gfx_text(10, 10, msg);/*Imprime as informacões do triangulo*/
								gfx_text(10, 30, "Atalhos: Zoom(i)n - Zoom(o)ut - (C)lear - (esc)ape");/*Imprime o menu*/
								break;

							case SDLK_c: /*Caso seja 'c' o triangulo é resetado*/
								size = default_size;/*Define o tamanho com o tamanho padrão*/
								gfx_clear();/*Limpa tela*/
								amount = 0;/*Zera o contador de triangulos*/
								sierpinski((gfx_get_width() / 2) - (size / 2), gfx_get_height() - (int)((size * 1.732050808) / 2), size, &amount);/*Desenha o triangulo com o tamanho padrão*/
								sprintf(msg, "Lado: %d     Quantidade: %u", size, amount);
								gfx_text(10, 10, msg);/*Imprime as informacões do triangulo*/
								gfx_text(10, 30, "Atalhos: Zoom(i)n - Zoom(o)ut - (C)lear - (esc)ape");/*Imprime o menu*/
								break;

							case SDLK_ESCAPE: /*Caso seja 'ESC' encerra o programa*/
								quit = 1;
								break;
							
							default:/*Outra tecla nada é feito*/
								break;
						}
						gfx_refresh();/*Atualiza a tela*/
						usleep(120000);/*Delay para ler um novo evento*/
						SDL_PollEvent(&event);/*Le um novo evento*/
					}
					break;
			}
		}
	}

	gfx_quit();/*Fecha a janela*/
	free(msg);/*Libera a memoria alocada*/
	return 0;
}
Beispiel #24
0
void background(int w,int h,int level)
{  
	int wnum=50,wseg=w/wnum,hnum=100,hseg=h/hnum,i,ic; //define parameters
   
	gfx_clear_color(0,0,0);
	gfx_clear();
	gfx_color(255,255,255); //white
 	gfx_text(w/2, h-20, "Use arrow keys to navigate frog safely to a lilly pad. Do not get hit by a car or fall in the water.");
 	gfx_text(w/4,h-20,"LEVEL: ");
 	gfx_text(w/4+50,h-20,num2str(level));
 
	gfx_color(20,0,150); //blue color
	gfx_fill_rectangle(0,0,w,h/2); //draws water
    
	gfx_color(20,150,0); //green color
	gfx_fill_rectangle(0,0,w,hseg); //draws top green border
    
	for(i=0;i<6;i++) //draws lily pads
    	for(ic=1;ic<(3*hseg);ic++) //increment radius to fill circle
        	gfx_circle((i*8+5)*wseg,5*hseg,ic);
       	 
	for(i=0;i<wnum;i++){ //draws pad details
    	if((i+2)%4!=0)
        	gfx_fill_rectangle(wseg*i*2,hseg,2*wseg,hseg);
       	 
    	if((i+1)%8<4){
        	switch((i+2)%4){
            	case 1:
                	gfx_fill_rectangle(wseg*i,2*hseg,wseg,hseg);
                	gfx_fill_rectangle(wseg*i,4*hseg,wseg,2*hseg);
                	break;
            	case 2:
                	gfx_fill_rectangle(wseg*i,3*hseg,wseg,2*hseg);
                	gfx_fill_rectangle(wseg*i,6*hseg,wseg,1*hseg);
                	break;
            	case 3:
                	gfx_fill_rectangle(wseg*i,2*hseg,wseg,2*hseg);
                	gfx_fill_rectangle(wseg*i,5*hseg,wseg,2*hseg);
                	break;
            	case 0:
                	gfx_fill_rectangle(wseg*i,2*hseg,wseg,hseg);
                	gfx_fill_rectangle(wseg*i,4*hseg,wseg,2*hseg);
                	break;
        	} //end switch((i+2)%4)
    	} //end if((i+1)%8<4)
   	 
    	switch(i%8){ //draw middle grass
            	case 0:
            	case 1:
            	case 3:
            	case 6:
                	gfx_fill_rectangle(wseg*i,(h/2)-(4*hseg),wseg,5*hseg);
                	break;
            	case 2:
            	case 7:
                	gfx_fill_rectangle(wseg*i,(h/2)-(5*hseg),wseg,7*hseg);
                	break;
            	case 4:
                	gfx_fill_rectangle(wseg*i,(h/2)-(4*hseg),wseg,6*hseg);
                	break;
            	case 5:
                	gfx_fill_rectangle(wseg*i,(h/2)-(5*hseg),wseg,6*hseg);
                	break;
        	} //end switch((i+2)%4)
       	 
    	switch(i%8){ //draw bottom grass
        	case 0:
        	case 1:
        	case 3:
        	case 6:
            	gfx_fill_rectangle(wseg*i,h-(18*hseg),wseg,5*hseg);
            	break;
        	case 2:
        	case 7:
            	gfx_fill_rectangle(wseg*i,h-(19*hseg),wseg,7*hseg);
            	break;
        	case 4:
            	gfx_fill_rectangle(wseg*i,h-(18*hseg),wseg,6*hseg);
            	break;
        	case 5:
            	gfx_fill_rectangle(wseg*i,h-(19*hseg),wseg,6*hseg);
            	break;
    	} //end switch((i+2)%4)
   	 
	} //end for(i=0;i<wnum;i++)
    
	gfx_color(150,75,0); //brown color
	for(i=0;i<wnum;i++){ //draws grass details
    	switch(i%8){ //draw middle grass details
            	case 0:
            	case 1: break;
            	case 3:
            	case 6:
                	gfx_fill_rectangle(wseg*i,(h/2)-(2*hseg),wseg,hseg);
                	break;
            	case 2:
            	case 7:
                	gfx_fill_rectangle(wseg*i,(h/2)-(4*hseg),wseg,hseg);
                	break;
            	case 4:
                	gfx_fill_rectangle(wseg*i,(h/2)-(3*hseg),wseg,hseg);
                	break;
            	case 5:
                	gfx_fill_rectangle(wseg*i,(h/2)-hseg,wseg,hseg);
                	break;
        	} //end switch((i+2)%4)
       	 
        	switch(i%8){ //draw bottom grass details
            	case 0:
            	case 1: break;
            	case 3:
            	case 6:
                	gfx_fill_rectangle(wseg*i,h-(16*hseg),wseg,hseg);
                	break;
            	case 2:
            	case 7:
                	gfx_fill_rectangle(wseg*i,h-(18*hseg),wseg,hseg);
                	break;
            	case 4:
                	gfx_fill_rectangle(wseg*i,h-(17*hseg),wseg,hseg);
                	gfx_fill_rectangle(wseg*i,h-(14*hseg),wseg,hseg);
                	break;
            	case 5:
                	gfx_fill_rectangle(wseg*i,h-(15*hseg),wseg,hseg);
                	break;
        	} //end switch((i+2)%4)
       	 
	} //end for(i=0;i<wnum;i++)
    
} //end background
Beispiel #25
0
char welcome(void)
{
	gfx_clear_color(0,255,0); //green
	gfx_clear();

	gfx_color(255,255,255);

	//Frogger
	gfx_fill_rectangle(50,160,40,140);
	gfx_fill_rectangle(90,160,100,20);
	gfx_fill_rectangle(90,220,80,20);

	//fRogger
	gfx_fill_rectangle(210,160,40,140);
	gfx_fill_rectangle(250,160,80,20);
	gfx_fill_rectangle(310,180,40,60);
	gfx_fill_rectangle(290,220,20,20);
	gfx_fill_rectangle(250,240,60,20);
	gfx_fill_rectangle(270,260,60,20);
	gfx_fill_rectangle(300,280,60,20);

	//frOgger
	gfx_fill_rectangle(370,180,40,100);
	gfx_fill_rectangle(470,180,40,100);
	gfx_fill_rectangle(390,160,100,20);
	gfx_fill_rectangle(390,280,100,20);

	//froGger
	gfx_fill_rectangle(570,160,100,20);  
	gfx_fill_rectangle(550,180,40,20);
	gfx_fill_rectangle(530,200,40,60);
	gfx_fill_rectangle(550,260,40,20);
	gfx_fill_rectangle(570,280,100,20);
	gfx_fill_rectangle(630,260,40,20);
	gfx_fill_rectangle(610,240,60,20);

	//frogGer
	gfx_fill_rectangle(730,160,100,20);  
	gfx_fill_rectangle(710,180,40,20);
	gfx_fill_rectangle(690,200,40,60);
	gfx_fill_rectangle(710,260,40,20);
	gfx_fill_rectangle(730,280,100,20);
	gfx_fill_rectangle(790,260,40,20);
	gfx_fill_rectangle(770,240,60,20);

	//froggEr
	gfx_fill_rectangle(850,160,40,140);
	gfx_fill_rectangle(890,160,100,20);
	gfx_fill_rectangle(890,220,80,20);
	gfx_fill_rectangle(890,280,100,20);

	//froggeR
	gfx_fill_rectangle(1010,160,40,140);
	gfx_fill_rectangle(1050,160,80,20);
	gfx_fill_rectangle(1110,180,40,60);
	gfx_fill_rectangle(1090,220,20,20);
	gfx_fill_rectangle(1050,240,60,20);
	gfx_fill_rectangle(1070,260,60,20);
	gfx_fill_rectangle(1100,280,60,20);

	gfx_text(530,325, "CSE20211: Final Project");
	gfx_text(510,345, "Sara Cunningham and Jenna Wilson");
	gfx_text(470,365, "Press any key to play Frogger. Press \'q\' to quit");

	return gfx_wait();
} //end welcome
Beispiel #26
0
char blood(void)
{
	gfx_clear_color(255,0,0);
	gfx_clear();

	gfx_color(255,255,255);

	//Game over
	gfx_fill_rectangle(330,160,100,20);  
	gfx_fill_rectangle(310,180,40,20);
	gfx_fill_rectangle(290,200,40,60);
	gfx_fill_rectangle(310,260,40,20);
	gfx_fill_rectangle(330,280,100,20);
	gfx_fill_rectangle(390,260,40,20);
	gfx_fill_rectangle(370,240,60,20);

	//gAme over
	gfx_fill_rectangle(450,200,40,100);
	gfx_fill_rectangle(470,180,40,20);
	gfx_fill_rectangle(490,160,60,20);
	gfx_fill_rectangle(530,180,40,20);
	gfx_fill_rectangle(550,200,40,100);
	gfx_fill_rectangle(490,240,60,20);

	//gaMe over
	gfx_fill_rectangle(610,160,40,140);
	gfx_fill_rectangle(650,180,20,40);
	gfx_fill_rectangle(670,200,20,40);
	gfx_fill_rectangle(690,180,20,40);
	gfx_fill_rectangle(710,160,40,140);

	//gamE over
	gfx_fill_rectangle(770,160,40,140);
	gfx_fill_rectangle(810,160,100,20);
	gfx_fill_rectangle(810,220,80,20);
	gfx_fill_rectangle(810,280,100,20);

	//game Over
	gfx_fill_rectangle(290,370,40,100);
	gfx_fill_rectangle(390,370,40,100);
	gfx_fill_rectangle(310,350,100,20);
	gfx_fill_rectangle(310,470,100,20);

	//game oVer
	gfx_fill_rectangle(450,350,40,80);
	gfx_fill_rectangle(550,350,40,80);
	gfx_fill_rectangle(470,430,40,20);
	gfx_fill_rectangle(530,430,40,20);
	gfx_fill_rectangle(490,450,60,20);
	gfx_fill_rectangle(510,470,20,20);

	//game ovEr
	gfx_fill_rectangle(610,350,40,140);
	gfx_fill_rectangle(650,350,100,20);
	gfx_fill_rectangle(650,410,80,20);
	gfx_fill_rectangle(650,470,100,20);

	//game oveR
	gfx_fill_rectangle(770,350,40,140);
	gfx_fill_rectangle(810,350,80,20);
	gfx_fill_rectangle(870,370,40,60);
	gfx_fill_rectangle(850,410,20,20);
	gfx_fill_rectangle(810,430,60,20);
	gfx_fill_rectangle(830,450,60,20);
	gfx_fill_rectangle(860,470,60,20);

	//directions to continue
	gfx_text(450, 520, "Press any key to play Frogger again. Press \'q\' to quit.");

	return gfx_wait();
} //end blood
Beispiel #27
0
void dispScore(void){
	gfx_color(24, 238, 0);
	gfx_text(3,10,"SCORE");//to be used to display score
	gfx_fill_rectangle(0,498,800,2);
}
void scoreboard(int cirCount)
{
	gfx_text(20, 20, num2str(cirCount));
}
Beispiel #29
0
void CONSOLE::on_render()
{
    RECT screen = *ui_screen();
	float console_max_height = screen.h*3/5.0f;
	float console_height;

	float progress = (time_now()-(state_change_end-state_change_duration))/float(state_change_duration);

	if (progress >= 1.0f)
	{
		if (console_state == CONSOLE_CLOSING)
			console_state = CONSOLE_CLOSED;
		else if (console_state == CONSOLE_OPENING)
			console_state = CONSOLE_OPEN;

		progress = 1.0f;
	}
		
	if (console_state == CONSOLE_CLOSED)
		return;
		
	if (console_state == CONSOLE_OPEN)
		inp_mouse_mode_absolute();

	float console_height_scale;

	if (console_state == CONSOLE_OPENING)
		console_height_scale = console_scale_func(progress);
	else if (console_state == CONSOLE_CLOSING)
		console_height_scale = console_scale_func(1.0f-progress);
	else //if (console_state == CONSOLE_OPEN)
		console_height_scale = console_scale_func(1.0f);

	console_height = console_height_scale*console_max_height;

	gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);

	// do console shadow
	gfx_texture_set(-1);
    gfx_quads_begin();
    gfx_setcolorvertex(0, 0,0,0, 0.5f);
    gfx_setcolorvertex(1, 0,0,0, 0.5f);
    gfx_setcolorvertex(2, 0,0,0, 0.0f);
    gfx_setcolorvertex(3, 0,0,0, 0.0f);
    gfx_quads_drawTL(0,console_height,screen.w,10.0f);
    gfx_quads_end();

	// do background
	gfx_texture_set(data->images[IMAGE_CONSOLE_BG].id);
    gfx_quads_begin();
    gfx_setcolor(0.2f, 0.2f, 0.2f,0.9f);
    if(console_type != 0)
	    gfx_setcolor(0.4f, 0.2f, 0.2f,0.9f);
    gfx_quads_setsubset(0,-console_height*0.075f,screen.w*0.075f*0.5f,0);
    gfx_quads_drawTL(0,0,screen.w,console_height);
    gfx_quads_end();

	// do small bar shadow
	gfx_texture_set(-1);
    gfx_quads_begin();
    gfx_setcolorvertex(0, 0,0,0, 0.0f);
    gfx_setcolorvertex(1, 0,0,0, 0.0f);
    gfx_setcolorvertex(2, 0,0,0, 0.25f);
    gfx_setcolorvertex(3, 0,0,0, 0.25f);
    gfx_quads_drawTL(0,console_height-20,screen.w,10);
    gfx_quads_end();

	// do the lower bar
	gfx_texture_set(data->images[IMAGE_CONSOLE_BAR].id);
    gfx_quads_begin();
    gfx_setcolor(1.0f, 1.0f, 1.0f, 0.9f);
    gfx_quads_setsubset(0,0.1f,screen.w*0.015f,1-0.1f);
    gfx_quads_drawTL(0,console_height-10.0f,screen.w,10.0f);
    gfx_quads_end();
    
    console_height -= 22.0f;
    
    INSTANCE *console = current_console();

	{
		float font_size = 10.0f;
		float row_height = font_size*1.25f;
		float x = 3;
		float y = console_height - row_height - 2;

		// render prompt		
		TEXT_CURSOR cursor;
		gfx_text_set_cursor(&cursor, x, y, font_size, TEXTFLAG_RENDER);

		RENDERINFO info;
		info.wanted_completion = console->completion_chosen;
		info.enum_count = 0;
		info.current_cmd = console->completion_buffer;
		gfx_text_set_cursor(&info.cursor, x, y+12.0f, font_size, TEXTFLAG_RENDER);

		const char *prompt = "> ";
		if(console_type)
		{
			if(client_state() == CLIENTSTATE_ONLINE)
			{
				if(client_rcon_authed())
					prompt = "rcon> ";
				else
					prompt = "ENTER PASSWORD> ";
			}
			else
				prompt = "NOT CONNECTED> ";
		}

		gfx_text_ex(&cursor, prompt, -1);
		
		// render console input
		gfx_text_ex(&cursor, console->input.get_string(), console->input.cursor_offset());
		TEXT_CURSOR marker = cursor;
		gfx_text_ex(&marker, "|", -1);
		gfx_text_ex(&cursor, console->input.get_string()+console->input.cursor_offset(), -1);
		
		// render version
		char buf[128];
		str_format(buf, sizeof(buf), "v%s", GAME_VERSION);
		float version_width = gfx_text_width(0, font_size, buf, -1);
		gfx_text(0, screen.w-version_width-5, y, font_size, buf, -1);

		// render possible commands
		if(console->input.get_string()[0] != 0)
		{
			console_possible_commands(console->completion_buffer, console->completion_flagmask, possible_commands_render_callback, &info);
			
			if(info.enum_count <= 0)
			{
				if(console->command)
				{
					
					char buf[512];
					str_format(buf, sizeof(buf), "Help: %s ", console->command->help);
					gfx_text_ex(&info.cursor, buf, -1);
					gfx_text_color(0.75f, 0.75f, 0.75f, 1);
					str_format(buf, sizeof(buf), "Syntax: %s %s", console->command->name, console->command->params);
					gfx_text_ex(&info.cursor, buf, -1);
				}
			}
		}
		gfx_text_color(1,1,1,1);

		// render log
		y -= row_height;
		char *entry = (char *)ringbuf_last(console->backlog);
		while (y > 0.0f && entry)
		{
			gfx_text(0, x, y, font_size, entry, -1);
			y -= row_height;

			entry = (char *)ringbuf_prev(console->backlog, entry);
		}
	}	
}
Beispiel #30
0
void HUD::render_goals()
{
	// TODO: split this up into these:
	// render_gametimer
	// render_suddendeath
	// render_scorehud
	// render_warmuptimer
	
	int gameflags = gameclient.snap.gameobj->flags;
	
	float whole = 300*gfx_screenaspect();
	float half = whole/2.0f;


	gfx_mapscreen(0,0,300*gfx_screenaspect(),300);
	if(!gameclient.snap.gameobj->sudden_death)
	{
		char buf[32];
		int time = 0;
		if(gameclient.snap.gameobj->time_limit)
		{
			time = gameclient.snap.gameobj->time_limit*60 - ((client_tick()-gameclient.snap.gameobj->round_start_tick)/client_tickspeed());

			if(gameclient.snap.gameobj->game_over)
				time  = 0;
		}
		else
			time = (client_tick()-gameclient.snap.gameobj->round_start_tick)/client_tickspeed();

		if(config.cl_render_time && !config.cl_clear_hud && !config.cl_clear_all)
		{
			str_format(buf, sizeof(buf), "%d:%02d", time /60, time %60);
			float w = gfx_text_width(0, 16, buf, -1);
			gfx_text(0, half-w/2, 2, 16, buf, -1);
		}
	}

	if((config.cl_render_time && !config.cl_clear_hud && !config.cl_clear_all) && gameclient.snap.gameobj->sudden_death)
	{
		const char *text = "Sudden Death";
		float w = gfx_text_width(0, 16, text, -1);
		gfx_text(0, half-w/2, 2, 16, text, -1);
	}

	// render small score hud
	if((config.cl_render_score && !config.cl_clear_hud && !config.cl_clear_all) && !(gameclient.snap.gameobj && gameclient.snap.gameobj->game_over) && (gameflags&GAMEFLAG_TEAMS))
	{
		for(int t = 0; t < 2; t++)
		{
			gfx_blend_normal();
			gfx_texture_set(-1);
			gfx_quads_begin();
			if(!config.tc_hud_match)
			{
				if(t == 0)
					gfx_setcolor(1,0,0,0.25f);
				else
					gfx_setcolor(0,0,1,0.25f);
			}
			else
			{
				vec3 col = TeecompUtils::getTeamColor(t, gameclient.snap.local_info->team,
					config.tc_colored_tees_team1, config.tc_colored_tees_team2, config.tc_colored_tees_method);
				gfx_setcolor(col.r, col.g, col.b, 0.25f);
			}

			draw_round_rect(whole-40, 300-40-15+t*20, 50, 18, 5.0f);
			gfx_quads_end();

			char buf[32];
			str_format(buf, sizeof(buf), "%d", t?gameclient.snap.gameobj->teamscore_blue:gameclient.snap.gameobj->teamscore_red);
			float w = gfx_text_width(0, 14, buf, -1);
			
			if(gameflags&GAMEFLAG_FLAGS)
			{
				gfx_text(0, whole-20-w/2+5, 300-40-15+t*20, 14, buf, -1);
				if(gameclient.snap.flags[t])
				{
					if(gameclient.snap.flags[t]->carried_by == -2 || (gameclient.snap.flags[t]->carried_by == -1 && ((client_tick()/10)&1)))
					{
						gfx_blend_normal();
						if(config.tc_colored_flags)
							gfx_texture_set(data->images[IMAGE_GAME_GRAY].id);
						else
							gfx_texture_set(data->images[IMAGE_GAME].id);
						gfx_quads_begin();

						if(t == 0) select_sprite(SPRITE_FLAG_RED);
						else select_sprite(SPRITE_FLAG_BLUE);
						
						if(config.tc_colored_flags)
						{
							vec3 col = TeecompUtils::getTeamColor(t,
								gameclient.snap.local_info->team,
								config.tc_colored_tees_team1,
								config.tc_colored_tees_team2,
								config.tc_colored_tees_method);
							gfx_setcolor(col.r, col.g, col.b, 1.0f);
						}

						float size = 16;					
						gfx_quads_drawTL(whole-40+5, 300-40-15+t*20+1, size/2, size);
						gfx_quads_end();
					}
					else if(gameclient.snap.flags[t]->carried_by >= 0)
					{
						int id = gameclient.snap.flags[t]->carried_by%MAX_CLIENTS;
						const char *name = gameclient.clients[id].name;
						float w = gfx_text_width(0, 10, name, -1);
						gfx_text(0, whole-40-5-w, 300-40-15+t*20+2, 10, name, -1);
						TEE_RENDER_INFO info = gameclient.clients[id].render_info;
						info.size = 18.0f;
						
						render_tee(ANIMSTATE::get_idle(), &info, EMOTE_NORMAL, vec2(1,0),
							vec2(whole-40+10, 300-40-15+9+t*20+1));
					}
				}
			}
			else
				gfx_text(0, whole-20-w/2, 300-40-15+t*20, 14, buf, -1);
		}
	}

	// render warmup timer
	if((config.cl_render_warmup && !config.cl_clear_all) && gameclient.snap.gameobj->warmup)
	{
		char buf[256];
		float w = gfx_text_width(0, 24, "Warmup", -1);
		gfx_text(0, 150*gfx_screenaspect()+-w/2, 50, 24, "Warmup", -1);

		int seconds = gameclient.snap.gameobj->warmup/SERVER_TICK_SPEED;
		if(seconds < 5)
			str_format(buf, sizeof(buf), "%d.%d", seconds, (gameclient.snap.gameobj->warmup*10/SERVER_TICK_SPEED)%10);
		else
			str_format(buf, sizeof(buf), "%d", seconds);
		w = gfx_text_width(0, 24, buf, -1);
		gfx_text(0, 150*gfx_screenaspect()+-w/2, 75, 24, buf, -1);
	}	
}