Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F126878
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/util/fire.cpp b/util/fire.cpp
index 5f953f9f..435bfeee 100644
--- a/util/fire.cpp
+++ b/util/fire.cpp
@@ -1,122 +1,127 @@
#include "bitmap.h"
#include <vector>
#include "fire.h"
#include <string.h>
#include "funcs.h"
#include <math.h>
class Bitmap;
namespace Paintown{
static int MAX_X = 320;
static int MAX_Y = 240;
Fire::Fire(){
- Util::blend_palette(colors, 64, Bitmap::makeColor(0, 0, 0), Bitmap::makeColor(255, 0, 0));
+ Util::blend_palette(colors, 64, Bitmap::makeColor(64, 0, 0), Bitmap::makeColor(255, 0, 0));
Util::blend_palette(colors + 64, 64, Bitmap::makeColor(255, 0, 0), Bitmap::makeColor(255, 255, 0));
- Util::blend_palette(colors + 64 + 64, 64, Bitmap::makeColor(255, 255, 0), Bitmap::makeColor(255, 255, 255));
- Util::blend_palette(colors + 64 + 64 + 64, 64, Bitmap::makeColor(255, 255, 255), Bitmap::makeColor(255, 255, 255));
+ Util::blend_palette(colors + 64 + 64, 96, Bitmap::makeColor(255, 255, 0), Bitmap::makeColor(255, 255, 255));
+ Util::blend_palette(colors + 64 + 64 + 64 + 32, 32, Bitmap::makeColor(255, 255, 255), Bitmap::makeColor(255, 255, 255));
data = new unsigned char*[MAX_Y];
for (int i = 0; i < MAX_Y; i++){
data[i] = new unsigned char[MAX_X];
memset(data[i], 0, MAX_X);
}
for (int i = 0; i < MAX_HOTSPOTS; i++){
hotspots[i] = Util::rnd(MAX_X);
directions[i] = 0;
}
}
void Fire::updateHotspots(){
for (int i = 0; i < MAX_HOTSPOTS; i++){
// hotspots[i] = (hotspots[i] + Util::rnd(5) - 2) % MAX_X;
hotspots[i] += directions[i];
if (hotspots[i] >= MAX_X){
hotspots[i] -= MAX_X;
}
if (hotspots[i] < 0){
hotspots[i] += MAX_X;
}
- directions[i] += (double) (Util::rnd(11) - 5) / 5.0;
+ directions[i] += (double) (Util::rnd(7) - 3) / 5.0;
if (directions[i] < -4){
directions[i] = -4;
}
if (directions[i] > 4){
directions[i] = 4;
}
}
- int hotspot_length = 30;
+ int hotspot_length = 40;
for (int i = 0; i < MAX_HOTSPOTS; i++){
for (int x = -hotspot_length/2; x < hotspot_length/2; x++){
int position = ((int) hotspots[i] + x + MAX_X) % MAX_X;
int more = (int) data[MAX_Y-1][position] + (hotspot_length / 2 - fabs(x));
if (more >= MAX_COLORS){
more = MAX_COLORS - 1;
}
data[MAX_Y-1][position] = more;
}
}
}
void Fire::update(){
updateHotspots();
int decay = 1;
for (int y = MAX_Y-1; y > 0; y--){
for (int x = 0; x < MAX_X; x++){
if (y < MAX_Y-1){
int lx = x-1;
if (lx < 0){
lx += MAX_X;
}
int rx = x+1;
if (rx >= MAX_X){
rx -= MAX_X;
}
// int less = (int)((double) data[y+1][x] * 0.6 + (double) data[y+1][lx] * 0.3 + (double) data[y+1][rx] * 0.3);
unsigned char * down = data[y+1];
// int less = (int)(((double) down[x]) * 0.9 + ((double) down[lx]) * 0.05 + ((double) down[rx]) * 0.05);
int less = (double) down[lx] * 0.20;
less += (double) down[rx] * 0.20;
- less += (double) down[x] * 0.60;
+ less += (double) down[x] * 0.62;
+ less -= Util::rnd(9);
if (less < 0){
less = 0;
}
if (less >= MAX_COLORS){
less = MAX_COLORS - 1;
}
data[y][x] = (unsigned char) less;
} else {
int less = (int)((double) data[y][x] * 0.95);
if (less < 0){
less = 0;
}
data[y][x] = (unsigned char) less;
}
}
}
}
void Fire::draw(const Bitmap & work){
+ // Bitmap::drawingMode(Bitmap::MODE_TRANS);
for (int y = 0; y < MAX_Y; y++){
for (int x = 0; x < MAX_X; x++){
// work.putPixel(x, y, colors[data[y][x]]);
- work.rectangleFill(x*2, y*2, x*2+1, y*2+1, colors[data[y][x]]);
+ if (data[y][x] > 0){
+ work.rectangleFill(x*2, y*2, x*2+1, y*2+1, colors[data[y][x]]);
+ }
}
}
+ // Bitmap::drawingMode(Bitmap::MODE_SOLID);
}
Fire::~Fire(){
for (int y = 0; y < MAX_Y; y++){
delete[] data[y];
}
delete[] data;
}
}
diff --git a/util/fire.h b/util/fire.h
index 13e3d455..42380b1f 100644
--- a/util/fire.h
+++ b/util/fire.h
@@ -1,32 +1,32 @@
#ifndef _paintown_fire_93c6678306f3542737be4288dc09cfa9
#define _paintown_fire_93c6678306f3542737be4288dc09cfa9
class Bitmap;
namespace Paintown{
class Fire{
public:
Fire();
void update();
void draw(const Bitmap & work);
virtual ~Fire();
protected:
void updateHotspots();
protected:
unsigned char ** data;
/* enough to fill an unsigned char */
static const int MAX_COLORS = 256;
int colors[MAX_COLORS];
- static const int MAX_HOTSPOTS = 15;
+ static const int MAX_HOTSPOTS = 10;
double hotspots[MAX_HOTSPOTS];
double directions[MAX_HOTSPOTS];
};
}
#endif
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jun 11, 1:25 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
69234
Default Alt Text
(5 KB)
Attached To
Mode
R75 R-Tech1
Attached
Detach File
Event Timeline