Skip to content

Commit 8c691c8

Browse files
Make difficulty halvers
1 parent 7a3a724 commit 8c691c8

File tree

6 files changed

+122
-39
lines changed

6 files changed

+122
-39
lines changed

.github/makecode/blocks.png

15.8 KB
Loading

.github/makecode/blocksdiff.png

-34.4 KB
Loading

images.g.jres

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
"mimeType": "image/x-mkcd-f4",
2020
"displayName": "buy_autoclicker_button"
2121
},
22-
"image6": {
23-
"data": "hwQQABAAAAD//////////x8RERERERHxH/////8fEfEfHxERER8R8R8fERERHxHxHx8REREfEfEfHxERER8f8R8fERER/x/xHx8RERH/H/EfHxERER8f8R8fERERHxHxHx8REREfEfEfHxERER8R8R//////HxHxHxEREREREfH//////////w==",
24-
"mimeType": "image/x-mkcd-f4",
25-
"displayName": "buy_computer_button"
26-
},
2722
"image4": {
2823
"data": "hwRSAAwAAAD///////8AAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAAfEREREfEAAB8RERER8QAAHxERERHxAAD///////8AAA==",
2924
"mimeType": "image/x-mkcd-f4",
@@ -50,9 +45,25 @@
5045
"displayName": "buy_asic_button"
5146
},
5247
"image11": {
53-
"data": "hwQIAAgAAAAAUABQAFAFVQBVVVVVVVUFVVVVBQBVVVUAUAVVAFAAUA==",
48+
"data": "hwQIAAgAAAAAYAAAAGYAAGBmAABmZmZmZmZmZmBmAAAAZgAAAGAAAA==",
49+
"mimeType": "image/x-mkcd-f4",
50+
"displayName": "arrow"
51+
},
52+
"image12": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
53+
"image6": {
54+
"data": "hwQQABAAAAD//////////x8RERERERHxH/////8fEfEfHxERER8R8R8fERERHxHxHx8REREfEfEfHxERER8f8R8fERER/x/xHx8RERH/H/EfHxERER8f8R8fERERHxHxHx8REREfEfEfHxERER8R8R//////HxHxHxEREREREfH//////////w==",
55+
"mimeType": "image/x-mkcd-f4",
56+
"displayName": "buy_computer_button"
57+
},
58+
"image13": {
59+
"data": "hwQMAAsAAAD/////DwAAAB8REREPAAAAHxEREQ8AAAAfERMRDwAAAB8RMxEPDwAAHzMzE/8PAAAfMzMT/w8AAB8RMxEPDwAAHxETEQ8AAAAfERERDwAAAB8REREPAAAA/////w8AAAA=",
60+
"mimeType": "image/x-mkcd-f4",
61+
"displayName": "difficulty_halver"
62+
},
63+
"image14": {
64+
"data": "hwQIAAgAAAAAAAMAAAAzAAAAMwMzMzMzMzMzMwAAMwMAADMAAAADAA==",
5465
"mimeType": "image/x-mkcd-f4",
55-
"displayName": "star"
66+
"displayName": "down_arrow"
5667
},
5768
"anim1": {
5869
"namespace": "myAnimations",

images.g.ts

Lines changed: 71 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,6 @@ f 1 1 1 1 1 1 1 f 1 f 1 1 1 1 f
6565
f 1 1 1 1 1 1 1 1 f f 1 1 1 1 f
6666
f 1 1 1 1 1 1 1 1 1 1 1 1 1 1 f
6767
f f f f f f f f f f f f f f f f
68-
`;
69-
case "image6":
70-
case "buy_computer_button":return img`
71-
f f f f f f f f f f f f f f f f
72-
f 1 1 1 1 1 1 1 1 1 1 1 1 1 1 f
73-
f 1 f f f f f f f f f f f f 1 f
74-
f 1 f 1 1 1 1 1 1 1 1 1 1 f 1 f
75-
f 1 f 1 1 1 1 1 1 1 1 1 1 f 1 f
76-
f 1 f 1 1 1 1 1 1 1 1 1 1 f 1 f
77-
f 1 f 1 1 1 1 1 1 1 1 1 1 f 1 f
78-
f 1 f 1 1 1 1 1 1 1 1 1 1 f 1 f
79-
f 1 f 1 1 1 1 1 1 1 1 1 1 f 1 f
80-
f 1 f 1 1 1 1 1 1 1 1 1 1 f 1 f
81-
f 1 f f f f f f f f f f f f 1 f
82-
f 1 1 1 1 1 1 f f 1 1 1 1 1 1 f
83-
f 1 1 1 1 1 f f f f 1 1 1 1 1 f
84-
f 1 1 1 1 1 1 1 1 1 1 1 1 1 1 f
85-
f 1 1 1 1 1 1 1 1 1 1 1 1 1 1 f
86-
f f f f f f f f f f f f f f f f
8768
`;
8869
case "image4":
8970
case "upgrades_button":return img`
@@ -157,15 +138,77 @@ f 1 1 1 1 1 1 1 1 1 1 1 1 1 1 f
157138
f f f f f f f f f f f f f f f f
158139
`;
159140
case "image11":
160-
case "star":return img`
161-
. . . 5 5 . . .
162-
. . . 5 5 . . .
163-
. . 5 5 5 5 . .
164-
5 5 5 5 5 5 5 5
165-
. 5 5 5 5 5 5 .
166-
. . 5 5 5 5 . .
167-
. 5 5 5 5 5 5 .
168-
5 5 5 . . 5 5 5
141+
case "arrow":return img`
142+
. . . 6 6 . . .
143+
. . 6 6 6 6 . .
144+
. 6 6 6 6 6 6 .
145+
6 6 6 6 6 6 6 6
146+
. . . 6 6 . . .
147+
. . . 6 6 . . .
148+
. . . 6 6 . . .
149+
. . . 6 6 . . .
150+
`;
151+
case "image12":return img`
152+
. . . . . . . . . . . . . . . .
153+
. . . . . . . . . . . . . . . .
154+
. . . . . . . . . . . . . . . .
155+
. . . . . . . . . . . . . . . .
156+
. . . . . . . . . . . . . . . .
157+
. . . . . . . . . . . . . . . .
158+
. . . . . . . . . . . . . . . .
159+
. . . . . . . . . . . . . . . .
160+
. . . . . . . . . . . . . . . .
161+
. . . . . . . . . . . . . . . .
162+
. . . . . . . . . . . . . . . .
163+
. . . . . . . . . . . . . . . .
164+
. . . . . . . . . . . . . . . .
165+
. . . . . . . . . . . . . . . .
166+
. . . . . . . . . . . . . . . .
167+
. . . . . . . . . . . . . . . .
168+
`;
169+
case "image6":
170+
case "buy_computer_button":return img`
171+
f f f f f f f f f f f f f f f f
172+
f 1 1 1 1 1 1 1 1 1 1 1 1 1 1 f
173+
f 1 f f f f f f f f f f f f 1 f
174+
f 1 f 1 1 1 1 1 1 1 1 1 1 f 1 f
175+
f 1 f 1 1 1 1 1 1 1 1 1 1 f 1 f
176+
f 1 f 1 1 1 1 1 1 1 1 1 1 f 1 f
177+
f 1 f 1 1 1 1 1 1 1 1 1 1 f 1 f
178+
f 1 f 1 1 1 1 1 1 1 1 1 1 f 1 f
179+
f 1 f 1 1 1 1 1 1 1 1 1 1 f 1 f
180+
f 1 f 1 1 1 1 1 1 1 1 1 1 f 1 f
181+
f 1 f f f f f f f f f f f f 1 f
182+
f 1 1 1 1 1 1 f f 1 1 1 1 1 1 f
183+
f 1 1 1 1 1 f f f f 1 1 1 1 1 f
184+
f 1 1 1 1 1 1 1 1 1 1 1 1 1 1 f
185+
f 1 1 1 1 1 1 1 1 1 1 1 1 1 1 f
186+
f f f f f f f f f f f f f f f f
187+
`;
188+
case "image13":
189+
case "difficulty_halver":return img`
190+
f f f f f f f f f f f f
191+
f 1 1 1 1 1 1 1 1 1 1 f
192+
f 1 1 1 1 3 3 1 1 1 1 f
193+
f 1 1 1 1 3 3 1 1 1 1 f
194+
f 1 1 3 3 3 3 3 3 1 1 f
195+
f 1 1 1 3 3 3 3 1 1 1 f
196+
f 1 1 1 1 3 3 1 1 1 1 f
197+
f 1 1 1 1 1 1 1 1 1 1 f
198+
f f f f f f f f f f f f
199+
. . . . . f f . . . . .
200+
. . . . f f f f . . . .
201+
`;
202+
case "image14":
203+
case "down_arrow":return img`
204+
. . . 3 3 . . .
205+
. . . 3 3 . . .
206+
. . . 3 3 . . .
207+
. . . 3 3 . . .
208+
3 3 3 3 3 3 3 3
209+
. 3 3 3 3 3 3 .
210+
. . 3 3 3 3 . .
211+
. . . 3 3 . . .
169212
`;
170213
}
171214
return null;

main.blocks

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

main.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ function load_progress () {
143143
difficulty_halve_time_left = blockSettings.readNumber("game_difficulty_halve_time_left")
144144
difficulty_halve_max_time = blockSettings.readNumber("game_difficulty_halve_max_time")
145145
difficulty_halve_chance = blockSettings.readNumber("game_difficulty_halve_chance")
146+
difficulty_halving = read_bool("game_difficulty_halving")
146147
}
147148
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
148149
if (sprite_cursor_pointer.overlapsWith(sprite_computer)) {
@@ -157,6 +158,8 @@ controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
157158
get_upgrades_menu()
158159
} else if (sprite_cursor_pointer.overlapsWith(sprite_menu_button)) {
159160
menu_menu()
161+
} else if (sprite_overlapping_kind(sprite_cursor_pointer, SpriteKind.Thing)) {
162+
difficulty_halving = true
160163
}
161164
})
162165
function menu_menu () {
@@ -195,6 +198,9 @@ function sprite_overlapping_kind (sprite: Sprite, kind: number) {
195198
}
196199
return false
197200
}
201+
function read_bool (name: string) {
202+
return blockSettings.readNumber(name) == 1
203+
}
198204
function buy_asic_menu () {
199205
local_menu_options = ["Cancel"]
200206
if (asic_count > 0) {
@@ -412,6 +418,7 @@ function set_default_save () {
412418
difficulty_halve_time_left = 0
413419
difficulty_halve_max_time = 30
414420
difficulty_halve_chance = 1
421+
difficulty_halving = false
415422
}
416423
function wipe_save () {
417424
for (let value of blockSettings.list()) {
@@ -469,6 +476,7 @@ function save_progress () {
469476
blockSettings.writeNumber("game_difficulty_halve_time_left", difficulty_halve_time_left)
470477
blockSettings.writeNumber("game_difficulty_halve_max_time", difficulty_halve_max_time)
471478
blockSettings.writeNumber("game_difficulty_halve_chance", difficulty_halve_chance)
479+
save_bool("game_difficulty_halving", difficulty_halving)
472480
}
473481
function enable_cursor (en: boolean) {
474482
if (en) {
@@ -479,6 +487,13 @@ function enable_cursor (en: boolean) {
479487
sprite_cursor_pointer.setFlag(SpriteFlag.Invisible, !(en))
480488
sprite_cursor.setFlag(SpriteFlag.Invisible, !(en))
481489
}
490+
function save_bool (name: string, value: boolean) {
491+
if (value) {
492+
blockSettings.writeNumber(name, 0)
493+
} else {
494+
blockSettings.writeNumber(name, 1)
495+
}
496+
}
482497
function make_menu_button () {
483498
sprite_menu_button = sprites.create(assets.image`menu_button`, SpriteKind.Shop)
484499
sprite_menu_button.left = sprite_upgrades_button.right + 2
@@ -510,7 +525,7 @@ function get_upgrades_menu () {
510525
local_menu_options.push("" + blockObject.getStringProperty(value, StrProp.name) + ": ($" + blockObject.getNumberProperty(value, NumProp.cost) + ") " + blockObject.getStringProperty(value, StrProp.description))
511526
local_upgrades_shown += 1
512527
}
513-
if (local_upgrades_shown >= 11) {
528+
if (local_upgrades_shown >= 10) {
514529
break;
515530
}
516531
}
@@ -542,6 +557,7 @@ blockMenu.onMenuOptionSelected(function (option, index) {
542557
function pretty_hashes_per_sec (hashes_per_sec: number) {
543558
return "" + number_to_si_prefix(hashes_per_sec) + "H/S: " + spriteutils.roundWithPrecision(hashes_per_sec / number_to_si_divider(hashes_per_sec), 2)
544559
}
560+
let sprite_difficulty_halver: Sprite = null
545561
let local_upgrade_got: blockObject.BlockObject = null
546562
let local_upgrades_shown = 0
547563
let local_available_upgrades: blockObject.BlockObject[] = []
@@ -556,6 +572,7 @@ let sprite_menu_button: Sprite = null
556572
let sprite_upgrades_button: Sprite = null
557573
let sprite_buy_autoclicker: Sprite = null
558574
let sprite_computer: Sprite = null
575+
let difficulty_halving = false
559576
let difficulty_halve_chance = 0
560577
let difficulty_halve_max_time = 0
561578
let difficulty_halve_time_left = 0
@@ -662,7 +679,19 @@ forever(function () {
662679
score_change = Math.ceil(score_change * 1.5)
663680
}
664681
Notification.waitForNotificationFinish()
665-
Notification.notify("Difficulty has been set to " + max_height + "!" + " (Reward is $" + score_change + ")", assets.image`star`)
682+
Notification.notify("Difficulty has been set to " + max_height + "!" + " (Reward is $" + score_change + ")", assets.image`arrow`)
683+
}
684+
pause(1000)
685+
})
686+
forever(function () {
687+
if ((Math.percentChance(difficulty_halve_chance) || true) && difficulty_halve_time_left <= 0) {
688+
sprite_difficulty_halver = sprites.create(assets.image`difficulty_halver`, SpriteKind.Thing)
689+
sprite_difficulty_halver.z = 30
690+
sprite_difficulty_halver.setPosition(randint(0, scene.screenWidth()), randint(0, scene.screenHeight()))
691+
sprite_difficulty_halver.setStayInScreen(true)
692+
sprite_difficulty_halver.startEffect(effects.halo, 1750)
693+
sprite_difficulty_halver.lifespan = 10000
694+
pause(10000)
666695
}
667696
pause(1000)
668697
})

0 commit comments

Comments
 (0)