summaryrefslogtreecommitdiff
path: root/World.cpp
blob: 1a3e9b5e7e6f7f5fbbcf30d7b7d8dde6cc7cb866 (plain)
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
#include "World.h"


World::World(int level)
{
	player.speed=0;
	player.x2=player.x=0;
	player.anim=0;
	// generate level
	player.y=bricks[0][0].altitude+1;
}

void World::sim(double time)
{
	player.x2+=time/1000.0*player.speed;
	player.anim=(int)(player.x2*5)%2;
	while(player.x2>1.0)
	{
		player.x2-=1;
		player.x+=1;
		
		player.speed--;
	}
}

void World::mouseclick(int x, int y)
{
	for(Brick &brick:bricks[x])
	{
		if(brick.type<=1&&brick.altitude==y)
		{
			return;
		}
		if(brick.type>1&&brick.altitude==y)
		{
			brick.type++;
			if(brick.type>=6)brick.type=2;
			return;
		}
		

	}
	bricks[x].push_back({y,2});
	player.speed++;
}