File: booster.cpp

package info (click to toggle)
rafkill 1.2.2-3.3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 13,268 kB
  • sloc: cpp: 13,508; makefile: 64; sh: 14
file content (81 lines) | stat: -rw-r--r-- 1,692 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "booster.h"
#include "bitmap.h"
#include "defs.h"

#define MAX_BOOSTER_SHADE 13

PixelList::PixelList( int ax, int ay, int l, PixelList * nx ) {
	x = ax;
	y = ay;
	next = nx;
	life = l;
}

int PixelList::Update(){
	life++;
	return life;
}

void PixelList::Draw( const Bitmap & work, int * shade, int offset ) const{
	// circlefill( work, x, y+offset, 1, shade[ life ] );
	work.circleFill( x, y+offset, 1, shade[ life ] );
}


Booster::Booster() {

	shade = new int[ MAX_BOOSTER_SHADE ];
	Util::blend_palette( shade, MAX_BOOSTER_SHADE*2/3, Bitmap::makeColor(244,220,12), Bitmap::makeColor(237,53,42) );
	Util::blend_palette( shade+MAX_BOOSTER_SHADE*2/3, (MAX_BOOSTER_SHADE-MAX_BOOSTER_SHADE*2/3), Bitmap::makeColor(237,53,42), Bitmap::makeColor(83,6,0) );
	head = new PixelList(0,0,0,NULL);

}


void Booster::add( int x, int y) {

	PixelList * temp = new PixelList( x, y, 0, head->next );
	head->next = temp;

}


void Booster::Draw( const Bitmap & work, int offset ) const{

	PixelList * cur = head;
	while ( cur->next != NULL ) {
		cur->next->Draw( work, shade, offset );
		cur = cur->next;

		/*
		if ( cur->next->Draw(work,shade,offset) >= MAX_BOOSTER_SHADE ) {
			PixelList * dump = cur->next;
			cur->next = cur->next->next;
			delete dump;
		} else cur = cur->next;
		*/
	}

}

void Booster::Update(){
	PixelList * cur = head;
	while ( cur->next != NULL ) {
		if ( cur->next->Update() >= MAX_BOOSTER_SHADE ) {
			PixelList * dump = cur->next;
			cur->next = cur->next->next;
			delete dump;
		} else cur = cur->next;
	}
}

Booster::~Booster() {
	delete shade;
	PixelList * cur = head;
	while ( cur != NULL ) {
		PixelList * dump = cur;
		cur = cur->next;
		delete dump;
	}

}