fixed the ninja rendering

This commit is contained in:
Magnus Auvinen 2008-03-10 19:36:05 +00:00
parent 3f3e171511
commit e7241d743c
7 changed files with 57 additions and 8 deletions

View file

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View file

@ -269,8 +269,8 @@ powerups {
}
ninja {
amount 1
respawntime 90
startspawntime 90
respawntime 5
startspawntime 0
}
}

View file

@ -146,6 +146,7 @@ void effect_air_jump(vec2 pos);
void effect_damage_indicator(vec2 pos, vec2 dir);
void effect_playerspawn(vec2 pos);
void effect_playerdeath(vec2 pos);
void effect_powerupshine(vec2 pos, vec2 size);
// particles
struct particle

View file

@ -25,6 +25,27 @@ void effect_air_jump(vec2 pos)
particle_add(PARTGROUP_GENERAL, &p);
}
void effect_powerupshine(vec2 pos, vec2 size)
{
if(!add_trail)
return;
particle p;
p.set_default();
p.spr = SPRITE_PART_SLICE;
p.pos = pos + vec2((frandom()-0.5f)*size.x, (frandom()-0.5f)*size.y);
p.vel = vec2(0, 0);
p.life_span = 0.5f;
p.start_size = 16.0f;
p.end_size = 0;
p.rot = frandom()*pi*2;
p.rotspeed = pi*2;
p.gravity = 500;
p.friction = 0.9f;
p.flow_affected = 0.0f;
particle_add(PARTGROUP_GENERAL, &p);
}
void effect_smoketrail(vec2 pos, vec2 vel)
{
if(!add_trail)

View file

@ -506,8 +506,12 @@ extern "C" void modc_message(int msg)
if(msg_unpack_error() || cid < 0 || cid >= MAX_CLIENTS)
return;
strncpy(client_datas[cid].name, name, 64);
strncpy(client_datas[cid].skin_name, skinname, 64);
str_copy(client_datas[cid].name, name, 64);
str_copy(client_datas[cid].skin_name, skinname, 64);
// make sure that we don't set a special skin on the client
if(client_datas[cid].skin_name[0] == 'x' || client_datas[cid].skin_name[1] == '_')
str_copy(client_datas[cid].skin_name, "default", 64);
int use_custom_color = msg_unpack_int();
client_datas[cid].skin_info.color_body = skin_get_color(msg_unpack_int());

View file

@ -1258,6 +1258,11 @@ static void menu2_render_settings_player(RECT main_view)
for(int i = start; i < start+num && i < skin_num(); i++)
{
const skin *s = skin_get(i);
// no special skins
if(s->name[0] == 'x' && s->name[1] == '_')
continue;
char buf[128];
str_format(buf, sizeof(buf), "%s", s->name);
int selected = 0;

View file

@ -9,6 +9,7 @@
#include "gc_render.h"
#include "gc_anim.h"
#include "gc_client.h"
#include "gc_skin.h"
void render_projectile(const NETOBJ_PROJECTILE *current, int itemid)
@ -89,10 +90,7 @@ void render_powerup(const NETOBJ_POWERUP *prev, const NETOBJ_POWERUP *current)
if(c[current->type] == SPRITE_POWERUP_NINJA)
{
/*
proj_particles.addparticle(0, 0,
pos+vec2((frandom()-0.5f)*80.0f, (frandom()-0.5f)*20.0f),
vec2((frandom()-0.5f)*10.0f, (frandom()-0.5f)*10.0f));*/
effect_powerupshine(pos, vec2(96,18));
size *= 2.0f;
pos.x += 10.0f;
}
@ -261,6 +259,10 @@ void render_player(
float intratick = client_intratick();
float ticktime = client_ticktime();
bool is_teamplay = false;
if(netobjects.gameobj && netobjects.gameobj->gametype != GAMETYPE_DM)
is_teamplay = true;
if(player.health < 0) // dont render dead players
return;
@ -396,6 +398,20 @@ void render_player(
}
else if (player.weapon == WEAPON_NINJA)
{
// change the skin for the player to the ninja
int skin = skin_find("x_ninja");
if(skin != -1)
{
if(is_teamplay)
render_info.texture = skin_get(skin)->color_texture;
else
{
render_info.texture = skin_get(skin)->org_texture;
render_info.color_body = vec4(1,1,1,1);
render_info.color_feet = vec4(1,1,1,1);
}
}
p = position;
p.y += data->weapons[iw].offsety;
@ -403,10 +419,12 @@ void render_player(
{
gfx_quads_setrotation(-pi/2-state.attach.angle*pi*2);
p.x -= data->weapons[iw].offsetx;
effect_powerupshine(p+vec2(32,0), vec2(32,12));
}
else
{
gfx_quads_setrotation(-pi/2+state.attach.angle*pi*2);
effect_powerupshine(p-vec2(32,0), vec2(32,12));
}
draw_sprite(p.x, p.y, data->weapons[iw].visual_size);