root / processing / blacklight / Blackminion.pde @ 17
Histórico | Ver | Anotar | Download (2,23 KB)
| 1 |
/* |
|---|---|
| 2 |
BLACKLIGHT v1.0 |
| 3 |
Project made for Mestrado de Comunicação Multimédia, Ramo Multimédia Interactivo at Departamento de Comunicação e Arte at Universidade de Aveiro. |
| 4 |
|
| 5 |
Author: Nuno Simaria - nsimaria@ua.pt - #23652 |
| 6 |
Other workgroup members: Ana Filipa Lacerda, Daniela Rei, Renato Costa, Julien Cuenin |
| 7 |
*/ |
| 8 |
|
| 9 |
class Blackminion |
| 10 |
{
|
| 11 |
int x = 200; |
| 12 |
int y = 200; |
| 13 |
int diameter = 20; |
| 14 |
Input input = null; |
| 15 |
Blacklord blacklord = null; |
| 16 |
|
| 17 |
boolean jammed = false; |
| 18 |
int timeout = 0; |
| 19 |
int charging = 0; |
| 20 |
|
| 21 |
void setup () |
| 22 |
{
|
| 23 |
|
| 24 |
} |
| 25 |
|
| 26 |
void draw () |
| 27 |
{
|
| 28 |
|
| 29 |
if (this.timeout != 0) |
| 30 |
{
|
| 31 |
this.timeout--; |
| 32 |
|
| 33 |
if (this.timeout <= 0) |
| 34 |
this.jammed = false; |
| 35 |
} |
| 36 |
|
| 37 |
if (this.charging > 0) |
| 38 |
this.charging--; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
this.x = this.x + (this.input.horizontal ()/10); |
| 43 |
this.y = this.y + (this.input.vertical ()/10); |
| 44 |
|
| 45 |
if (this.x >= _game_.width - 20 - this.diameter) |
| 46 |
this.x = _game_.width - 20 - this.diameter; |
| 47 |
if (this.y >= _game_.height - 20 - this.diameter) |
| 48 |
this.y = _game_.height - 20 - this.diameter; |
| 49 |
if (this.x <= this.diameter + 20) |
| 50 |
this.x = this.diameter + 20; |
| 51 |
if (this.y <= this.diameter + 20) |
| 52 |
this.y = this.diameter + 20; |
| 53 |
|
| 54 |
// if (this.input.fire () && (this.jammed == false)) |
| 55 |
// {
|
| 56 |
// println ("FIRE!!!");
|
| 57 |
this.fire (); |
| 58 |
// this.jammed = true; |
| 59 |
// this.timeout = 10; |
| 60 |
// _game_.playBlackFire (); |
| 61 |
// } |
| 62 |
if (this.input.fire () && (this.charging == 0)) |
| 63 |
{
|
| 64 |
this.bomb (); |
| 65 |
this.charging = 30; |
| 66 |
// _game_.playBlackBomb (); |
| 67 |
} |
| 68 |
|
| 69 |
fill (1); |
| 70 |
stroke (255, 75); |
| 71 |
strokeWeight (3); |
| 72 |
ellipse (this.x, this.y, this.diameter, this.diameter); |
| 73 |
strokeWeight (1); |
| 74 |
} |
| 75 |
|
| 76 |
void fire () |
| 77 |
{
|
| 78 |
|
| 79 |
Blackmatter matter = new Blackmatter (); |
| 80 |
|
| 81 |
matter.x = this.x; |
| 82 |
matter.y = this.y; |
| 83 |
|
| 84 |
matter.setup (); |
| 85 |
this.blacklord.blackmatter.add (matter); |
| 86 |
|
| 87 |
} |
| 88 |
|
| 89 |
void bomb () |
| 90 |
{
|
| 91 |
for (int i = 0; i < 10; i++) |
| 92 |
{
|
| 93 |
Blackmatter matter = new Blackmatter (); |
| 94 |
|
| 95 |
matter.x = int (random (20, _game_.width - 20)); |
| 96 |
matter.y = int (random (20, _game_.height - 20)); |
| 97 |
|
| 98 |
matter.setup (); |
| 99 |
this.blacklord.blackmatter.add (matter); |
| 100 |
} |
| 101 |
} |
| 102 |
} |