mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Updated stuff
This commit is contained in:
parent
b6c9c311c5
commit
1120a86b25
|
@ -336,7 +336,39 @@ public:
|
|||
};
|
||||
|
||||
static particle_system temp_system;
|
||||
|
||||
|
||||
class projectile_particles
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
LISTSIZE = 1000,
|
||||
};
|
||||
// meh, just use size %
|
||||
int lastadd[LISTSIZE];
|
||||
projectile_particles()
|
||||
{
|
||||
for (int i = 0; i < LISTSIZE; i++)
|
||||
lastadd[i] = -1000;
|
||||
}
|
||||
|
||||
void addparticle(int projectiletype, int projectileid, vec2 pos, vec2 vel)
|
||||
{
|
||||
int particlespersecond = data->projectileparticles[projectiletype].particlespersecond;
|
||||
int lastaddtick = lastadd[projectileid % LISTSIZE];
|
||||
if ((client_tick() - lastaddtick) > (client_tickspeed() / particlespersecond))
|
||||
{
|
||||
lastadd[projectileid % LISTSIZE] = client_tick();
|
||||
float life = data->projectileparticles[projectiletype].particlelife;
|
||||
float size = data->projectileparticles[projectiletype].particlesize;
|
||||
vec2 v = vel * 0.2f + normalize(vec2(frandom()-0.5f, -frandom()))*(32.0f+frandom()*32.0f);
|
||||
|
||||
// add the particle (from projectiletype later on, but meh...)
|
||||
temp_system.new_particle(pos, v, life, size, 0, 0.95f);
|
||||
}
|
||||
}
|
||||
};
|
||||
static projectile_particles proj_particles;
|
||||
|
||||
static bool chat_active = false;
|
||||
static char chat_input[512];
|
||||
|
@ -504,6 +536,31 @@ void modc_newsnapshot()
|
|||
temp_system.new_particle(p, v, 0.5f+0.5f*frandom(), 16.0f, 128.0f, 0.985f);
|
||||
}
|
||||
}
|
||||
else if(item.type == EVENT_DEATH)
|
||||
{
|
||||
ev_explosion *ev = (ev_explosion *)data;
|
||||
vec2 p(ev->x, ev->y);
|
||||
|
||||
// center explosion
|
||||
vec2 v = normalize(vec2(frandom()-0.5f, -frandom()))*(32.0f+frandom()*32.0f);
|
||||
temp_system.new_particle(p, v, 1.2f, 64.0f, 0, 0.95f);
|
||||
v = normalize(vec2(frandom()-0.5f, -frandom()))*(128.0f+frandom()*128.0f);
|
||||
temp_system.new_particle(p, v, 1.2f, 32.0f, 0, 0.95f);
|
||||
v = normalize(vec2(frandom()-0.5f, -frandom()))*(128.0f+frandom()*128.0f);
|
||||
temp_system.new_particle(p, v, 1.2f, 16.0f, 0, 0.95f);
|
||||
|
||||
for(int i = 0; i < 8; i++)
|
||||
{
|
||||
vec2 v = normalize(vec2(frandom()-0.5f, frandom()-0.5f))*(64.0f+frandom()*64.0f);
|
||||
temp_system.new_particle(p, v, 0.5f+0.5f*frandom(), 16.0f, 0, 0.985f);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 8; i++)
|
||||
{
|
||||
vec2 v = normalize(vec2(frandom()-0.5f, frandom()-0.5f))*(128.0f+frandom()*256.0f);
|
||||
temp_system.new_particle(p, v, 0.5f+0.5f*frandom(), 16.0f, 128.0f, 0.985f);
|
||||
}
|
||||
}
|
||||
else if(item.type == EVENT_SOUND)
|
||||
{
|
||||
ev_sound *ev = (ev_sound *)data;
|
||||
|
@ -524,7 +581,7 @@ void modc_newsnapshot()
|
|||
}
|
||||
}
|
||||
|
||||
static void render_projectile(obj_projectile *prev, obj_projectile *current)
|
||||
static void render_projectile(obj_projectile *prev, obj_projectile *current, int itemid)
|
||||
{
|
||||
gfx_texture_set(data->images[IMAGE_WEAPONS].id);
|
||||
gfx_quads_begin();
|
||||
|
@ -533,6 +590,9 @@ static void render_projectile(obj_projectile *prev, obj_projectile *current)
|
|||
vec2 vel = mix(vec2(prev->vx, prev->vy), vec2(current->vx, current->vy), client_intratick());
|
||||
vec2 pos = mix(vec2(prev->x, prev->y), vec2(current->x, current->y), client_intratick());
|
||||
|
||||
// add particle for this projectile
|
||||
proj_particles.addparticle(current->type, itemid, pos, vel);
|
||||
|
||||
if(length(vel) > 0.00001f)
|
||||
gfx_quads_setrotation(get_angle(vel));
|
||||
else
|
||||
|
@ -719,6 +779,13 @@ static void render_player(obj_player *prev, obj_player *player)
|
|||
if(player->health < 0) // dont render dead players
|
||||
return;
|
||||
|
||||
if (prev->health < 0)
|
||||
{
|
||||
// Don't flicker from previous position
|
||||
prev->x = player->x;
|
||||
prev->y = player->y;
|
||||
}
|
||||
|
||||
vec2 direction = get_direction(player->angle);
|
||||
float angle = player->angle/256.0f;
|
||||
vec2 position = mix(vec2(prev->x, prev->y), vec2(player->x, player->y), client_intratick());
|
||||
|
@ -1090,7 +1157,7 @@ void modc_render()
|
|||
{
|
||||
void *prev = snap_find_item(SNAP_PREV, item.type, item.id);
|
||||
if(prev)
|
||||
render_projectile((obj_projectile *)prev, (obj_projectile *)data);
|
||||
render_projectile((obj_projectile *)prev, (obj_projectile *)data, item.id);
|
||||
}
|
||||
else if(item.type == OBJTYPE_POWERUP)
|
||||
{
|
||||
|
|
|
@ -39,6 +39,7 @@ enum
|
|||
EVENT_SOUND,
|
||||
EVENT_SMOKE,
|
||||
EVENT_SPAWN,
|
||||
EVENT_DEATH,
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -85,6 +86,11 @@ struct ev_spawn
|
|||
int x, y;
|
||||
};
|
||||
|
||||
struct ev_death
|
||||
{
|
||||
int x, y;
|
||||
};
|
||||
|
||||
struct ev_sound
|
||||
{
|
||||
int x, y;
|
||||
|
|
|
@ -31,6 +31,7 @@ void create_damageind(vec2 p, vec2 dir, int amount);
|
|||
void create_explosion(vec2 p, int owner, int weapon, bool bnodamage);
|
||||
void create_smoke(vec2 p);
|
||||
void create_spawn(vec2 p);
|
||||
void create_death(vec2 p);
|
||||
void create_sound(vec2 pos, int sound, int loopflags = 0);
|
||||
class player *intersect_player(vec2 pos0, vec2 pos1, vec2 &new_pos, class entity *notthis = 0);
|
||||
|
||||
|
@ -1137,6 +1138,7 @@ void player::die(int killer, int weapon)
|
|||
dead = true;
|
||||
die_tick = server_tick();
|
||||
clear_flag(entity::FLAG_ALIVE);
|
||||
create_death(pos);
|
||||
}
|
||||
|
||||
bool player::take_damage(vec2 force, int dmg, int from, int weapon)
|
||||
|
@ -1410,6 +1412,14 @@ void create_spawn(vec2 p)
|
|||
ev->y = (int)p.y;
|
||||
}
|
||||
|
||||
void create_death(vec2 p)
|
||||
{
|
||||
// create the event
|
||||
ev_death *ev = (ev_death *)events.create(EVENT_DEATH, sizeof(ev_death));
|
||||
ev->x = (int)p.x;
|
||||
ev->y = (int)p.y;
|
||||
}
|
||||
|
||||
void create_sound(vec2 pos, int sound, int loopingflags)
|
||||
{
|
||||
if (sound < 0)
|
||||
|
|
Loading…
Reference in a new issue