Skip to content

Commit

Permalink
fixed the ninja rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Magnus Auvinen committed Mar 10, 2008
1 parent 3f3e171 commit e7241d7
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 8 deletions.
File renamed without changes
4 changes: 2 additions & 2 deletions datasrc/teewars.ds
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ powerups {
}
ninja {
amount 1
respawntime 90
startspawntime 90
respawntime 5
startspawntime 0
}
}

Expand Down
1 change: 1 addition & 0 deletions src/game/client/gc_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions src/game/client/gc_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions src/game/client/gc_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
5 changes: 5 additions & 0 deletions src/game/client/gc_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 22 additions & 4 deletions src/game/client/gc_render_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -396,17 +398,33 @@ 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;

if(direction.x < 0)
{
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);

Expand Down

0 comments on commit e7241d7

Please sign in to comment.