-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathxmas.cpp
55 lines (37 loc) · 1.19 KB
/
xmas.cpp
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
#include "32blit.hpp"
#include "assets.hpp"
using namespace blit;
typedef struct shape {
std::vector<Vec3> points ;
} shape;
shape snowflakes;
Surface *snow;
int snowsize = 500;
float speed = 20;
void init() {
set_screen_mode(ScreenMode::hires);
for (int i=0; i < 100; i++)
snowflakes.points.push_back(Vec3(rand() % screen.bounds.w, rand() % screen.bounds.h, rand() % 100));
snow = Surface::load(snowflake);
}
void render(uint32_t time) {
screen.pen = Pen(0,0,0);
screen.clear();
for (auto &p: snowflakes.points) {
screen.stretch_blit(snow,Rect(0,0,256,256),Rect(p.x, p.y, p.z * screen.bounds.w / snowsize, p.z * screen.bounds.h / snowsize));
p.y += p.z / speed ;
if (p.y > screen.bounds.h) {
p.x = rand() % screen.bounds.w ;
p.y = -50;
}
p.x += tilt.x * p.z ;
if (p.x > screen.bounds.w) p.x = -50;
if (p.x < -50 ) p.x = screen.bounds.w;
}
}
void update(uint32_t time) {
if (pressed(Button::DPAD_UP) && snowsize > 200) snowsize--;
if (pressed(Button::DPAD_DOWN) && snowsize < 1000) snowsize++;
if (pressed(Button::DPAD_RIGHT) && speed > 4) speed -= 0.1f;
if (pressed(Button::DPAD_LEFT) && speed < 200) speed += 0.1f;
}