File: boringball.cpp

package info (click to toggle)
late 0.1.0-15
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,560 kB
  • sloc: cpp: 3,100; sh: 3,003; ansic: 164; makefile: 106
file content (100 lines) | stat: -rw-r--r-- 1,715 bytes parent folder | download | duplicates (7)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "boringball.h"
#include "graphics.h"
#include "game.h"
using namespace std;

static unsigned int boringballbmp;
static bool boringballbmpassigned;


boringball::boringball(ball * pack)
{
  package = pack;
  animate = 0;
  animatestate = 0;
}
void boringball::display()
{
  if (boringballbmpassigned == 0)
    {
      boringballbmp = load_bmpstrip("firestrip.bmp",14);
      boringballbmpassigned = 1;
    }

  int pic;
  pic = boringballbmp + int(animate);

  display_bmp(pic, int(center.x) - bmp_size(pic).x / 2,
	      int (center.y) - bmp_size(pic).y / 2 + 5); 
}

ball_base * boringball::duplicate(ball * pack)
{
  boringball * output = new boringball(pack);
  output->animate = animate;
  output->animatestate = animatestate;  
  output->setcenter(center);
  output->setvelocity(velocity);
  output->setboundary(boundary);
  output->animate = animate;
  return output;
}

void boringball::update(float amount)
{
  ball_base::update(amount);



  if (animatestate == 0)
    {
      animate += 0.05 * amount;
      if (animate >= 14)
	animate = 4;
      return;
    }
  if (animatestate == 1)
    {
      animate -= 0.1 * amount;
      if (animate <= 3)
	{
	  animatestate = 0;
	  animate = 0;
	}
      return;
    }
  if (animatestate == 2)
    {
      animate += 0.1 * amount;
      if (animate >= 10)
	{
	  animatestate = 1;
	  animate = 9.9;
	}
      return;
    }
  if (animatestate == 3)
    {
      animate -= 0.1 * amount;
      if (animate <= 1)
	{
	  animatestate = 2;
	  animate = 1;
	}
      return;
    }
  
}

void boringball::specialcollide(ball * other)
{
  animatestate = 3;
  other->specialcollideb(package);
}

void boringball::specialcollideb(ball * other)
{
  animatestate = 3;
}