Skip to content

Commit 94b7cbc

Browse files
committed
Added limit to the level variable and updated the version number to "1.1"
1 parent 5b2fdba commit 94b7cbc

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

src/main.HC

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,31 +63,34 @@ RegExe(PROGRAM_NAME);
6363

6464
U0 generateLevel(U8 level) {
6565
blockCount = 0;
66-
blockSize[0] = SCREEN_WIDTH / level;
67-
blockSize[1] = SCREEN_HEIGHT / (level * 1.5);
6866

69-
for (i = 0; i < level; i++) {
70-
oldRandomColor = randomColor;
67+
if (level) {
68+
blockSize[0] = SCREEN_WIDTH / level;
69+
blockSize[1] = SCREEN_HEIGHT / (level * 1.5);
7170

72-
while (randomColor == oldRandomColor) {
73-
randomColor = randomColors[RandU16() % 12];
74-
}
71+
for (i = 0; i < level; i++) {
72+
oldRandomColor = randomColor;
73+
74+
while (randomColor == oldRandomColor) {
75+
randomColor = randomColors[RandU16() % 12];
76+
}
77+
78+
for (j = 0; j < level; j++) {
79+
blockCount++;
80+
entity_init(
81+
&blocks[j][i],
82+
randomColor,
83+
ENTITY_DIR_NONE,
84+
blockSize[0],
85+
blockSize[1],
86+
j * blockSize[0],
87+
i * blockSize[1],
88+
0,
89+
TRUE
90+
);
91+
}
7592

76-
for (j = 0; j < level; j++) {
77-
blockCount++;
78-
entity_init(
79-
&blocks[j][i],
80-
randomColor,
81-
ENTITY_DIR_NONE,
82-
blockSize[0],
83-
blockSize[1],
84-
j * blockSize[0],
85-
i * blockSize[1],
86-
0,
87-
TRUE
88-
);
8993
}
90-
9194
}
9295
return;
9396
}
@@ -129,7 +132,9 @@ U0 reset() {
129132
U0 draw(CTask *task, CDC *dc) {
130133
if (!blockCount) {
131134
score += timer / 4;
132-
level++;
135+
if (level < BLOCK_MAX_SIZE) {
136+
level++;
137+
}
133138
init(level, &player);
134139
}
135140

src/progInfo.HH

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define __PROGINFO__
2020

2121
#define PROGRAM_NAME "BlockBreakHC"
22-
#define PROGRAM_VERSION "1.0"
22+
#define PROGRAM_VERSION "1.1"
2323

2424
#define SCREEN_WIDTH 640
2525
#define SCREEN_HEIGHT 472
@@ -35,7 +35,7 @@
3535
#define PLAYER_HEIGHT 16
3636

3737
#define PLAYER_START_X (SCREEN_WIDTH / 2) - (PLAYER_WIDTH / 2)
38-
#define PLAYER_START_Y (SCREEN_HEIGHT - PLAYER_HEIGHT) - 24
38+
#define PLAYER_START_Y (SCREEN_HEIGHT - PLAYER_HEIGHT) - 24
3939

4040
#define BLOCK_MAX_SIZE 255
4141

0 commit comments

Comments
 (0)