summaryrefslogtreecommitdiff
path: root/src/elements/prto.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/elements/prto.c')
-rw-r--r--src/elements/prto.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/elements/prto.c b/src/elements/prto.c
index 8f743e7..9bec996 100644
--- a/src/elements/prto.c
+++ b/src/elements/prto.c
@@ -1,17 +1,19 @@
#include <element.h>
int update_PRTO(UPDATE_FUNC_ARGS) {
- int r, nnx, rx, ry, np;
+ int r, nnx, rx, ry, np, fe = 0;
int count = 0;
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
else if (parts[i].tmp<0) parts[i].tmp = 0;
- for (rx=-1; rx<2; rx++)
- for (ry=-1; ry<2; ry++)
+ for (rx=1; rx>-2; rx--)
+ for (ry=1; ry>-2; ry--)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
count ++;
+ if (!r)
+ fe = 1;
if ((r>>8)>=NPART || r)
continue;
if (!r)
@@ -21,8 +23,8 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
int randomness = count + rand()%3-1;
if (randomness<1)
randomness=1;
- if (randomness>8)
- randomness=8;
+ if (randomness>9)
+ randomness=9;
if (portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)// TODO: make it look better
{
create_part(-1,x+1,y,portal[parts[i].tmp][randomness-1][nnx]);
@@ -51,5 +53,30 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
}
}
}
+ if(fe){
+ if(!parts[i].life) parts[i].life = rand();
+ if(!parts[i].ctype) parts[i].life = rand();
+ int orbd[4] = {0, 0, 0, 0}; //Orbital distances
+ int orbl[4] = {0, 0, 0, 0}; //Orbital locations
+ orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
+ for(r = 0; r < 4; r++){
+ if(orbd[r]<254){
+ orbd[r] += 16;
+ if(orbd[r]>254){
+ orbd[r] = 0;
+ orbl[r] = rand()%255;
+ }
+ //orbl[r] += 1;
+ //orbl[r] = orbl[r]%255;
+ } else {
+ orbd[r] = 0;
+ orbl[r] = rand()%255;
+ }
+ }
+ orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl);
+ } else {
+ parts[i].life = 0;
+ parts[i].ctype = 0;
+ }
return 0;
}