Skip to content

Commit

Permalink
Merge pull request #32 from IdeaSeeker/sync-tap-attack
Browse files Browse the repository at this point in the history
Sync tap attack (and not only)
  • Loading branch information
mmvpm authored Dec 5, 2021
2 parents 0353f55 + dc917e4 commit 629b517
Show file tree
Hide file tree
Showing 35 changed files with 616 additions and 31 deletions.
10 changes: 10 additions & 0 deletions RandomForest/RandomForest.yyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion RandomForest/objects/oDebug/Create_0.gml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
self.frame_counter = 0
self.frame_counter = 0

self.debug_password = "DEBUG" // only CAPSLOCK
self.debug_current_index = 1 // one-indexed
41 changes: 36 additions & 5 deletions RandomForest/objects/oDebug/Step_0.gml
Original file line number Diff line number Diff line change
@@ -1,18 +1,49 @@
if (keyboard_check_pressed(ord("R"))) {
self.frame_counter += 1


// switch to debug mode
if ( keyboard_check_pressed(string_ord_at(self.debug_password, self.debug_current_index)) ) {
self.debug_current_index += 1
}
if (self.debug_current_index > string_length(self.debug_password)) {
global.is_debug = !global.is_debug
self.debug_current_index = 1
audio_play_sound(soundCoinCollecting, 0, false) // just because
funSaveGameState()
}


// if production
if (!global.is_debug) {
return
}

// settings
if (keyboard_check_pressed(ord("R"))) { // reset saved level number
funResetGeneral()
}
if (keyboard_check_pressed(ord("T"))) {
if (keyboard_check_pressed(ord("T"))) { // reset saved time records
funResetRecords()
}
if (keyboard_check_pressed(ord("N"))) { // to next level
room_goto_next()
}
if (keyboard_check_pressed(ord("P"))) { // to previous level
room_goto_previous()
}
if (keyboard_check_pressed(ord("Q"))) { // auto collect all coins
oCoinCollector.coins_collected += instance_number(oCoin)
instance_destroy(oCoin)
}

// messages
if (self.frame_counter % 60 == 0) {
show_debug_message("is_fullscreen: " + string(global.is_fullscreen))
show_debug_message("current_level: " + string(global.current_level))
show_debug_message("is_game_finished: " + string(global.is_game_finished))
show_debug_message("is_training_completed: " + string(global.is_training_completed))
for (var i = 0; i < 2; ++i) {
show_debug_message("global.time_records[" + string(i) + "]: " + string(global.time_records[i]))
}
show_debug_message("\n")
}

self.frame_counter += 1
}
4 changes: 4 additions & 0 deletions RandomForest/objects/oFullscreen/Create_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// custom alarm[0] mechanism doesn't work because of $#*@%!!!
// so:
self.alarm_counter_max = 10 // frames = attempts
self.alarm_counter = 0
17 changes: 17 additions & 0 deletions RandomForest/objects/oFullscreen/Step_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// switch mode
if (keyboard_check_pressed(global.key_fullscreen)) {
global.is_fullscreen = !global.is_fullscreen
funSaveGameState()
}

// update state (+ for external changes)
if (window_get_fullscreen() != global.is_fullscreen) {
funUpdateFullscreen()
self.alarm_counter = self.alarm_counter_max // for centering
}

// beg the window to center (please...)
if (self.alarm_counter != 0) {
self.alarm_counter -= 1
window_center()
}
34 changes: 34 additions & 0 deletions RandomForest/objects/oFullscreen/oFullscreen.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions RandomForest/objects/oLoading/Alarm_0.gml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/// @description Go to next level

window_center()

// Load saved state
funLoadGameState()
alarm[0] = false

// go to next room
if (global.is_training_completed) {
Expand Down
20 changes: 12 additions & 8 deletions RandomForest/objects/oLoading/Create_0.gml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
/// @description Initializing the game

// Load saved state

funLoadGameState()


//Game window resizing

global.scale = 3

var cam = room_get_camera(rLevel00, 0)
var cam_width = camera_get_view_width(cam)
var cam_height = camera_get_view_height(cam)
var window_width_scaled = cam_width * global.scale
var window_height_scaled = cam_height * global.scale

var viewport = room_get_viewport(rLevel00, 0)

for (var i = 0; i < room_last; i++) {
if (i == rLoading) {
continue
}

for (var i = room_first; i != -1; i = room_next(i)) {
var viewport = room_get_viewport(i, 0)
room_set_camera(i, 0, cam)
room_set_viewport(i, 0,
viewport[0], viewport[1], viewport[2],
window_width_scaled, window_height_scaled
Expand All @@ -25,9 +28,9 @@ for (var i = 0; i < room_last; i++) {
surface_resize(application_surface, cam_width, cam_height)

window_set_size(window_width_scaled, window_height_scaled)
alarm[0] = true // for centering
display_set_gui_maximize(global.scale, global.scale, 0, 0)

funUpdateFullscreen()
alarm[0] = true // for centering

// Temporary config

Expand All @@ -44,3 +47,4 @@ global.key_arrow_up = vk_up
global.key_arrow_down = vk_down

global.key_pause = vk_escape
global.key_fullscreen = ord("F")
4 changes: 2 additions & 2 deletions RandomForest/objects/oPauseMenu/Draw_0.gml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
if (self.paused) {
gpu_set_tex_filter(true)

var cam = view_camera[0]
draw_sprite(self.screenshot, 0,
camera_get_view_x(cam),
camera_get_view_y(cam)
)
}
}
19 changes: 13 additions & 6 deletions RandomForest/objects/oPauseMenu/Step_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,30 @@ if (keyboard_check_pressed(global.key_pause)) {

if (self.paused) {
instance_deactivate_all(true)

instance_activate_object(oDebug)
instance_activate_object(oFullscreen)

if (keyboard_check_pressed(vk_enter)) {
if (self.current_index == 0) {
self.paused = false
} else if (self.current_index == 1) {
}
else if (self.current_index == 1) {
room_restart()
} else if (self.current_index == 2) {
}
else if (self.current_index == 2) {
game_end()
}
} else if (keyboard_check_pressed(vk_down)) {
}
else if (keyboard_check_pressed(vk_down)) {
self.current_index += 1
self.current_index %= self.items_count
} else if (keyboard_check_pressed(vk_up)) {
}
else if (keyboard_check_pressed(vk_up)) {
self.current_index += (self.items_count - 1)
self.current_index %= self.items_count
}
} else {
}
else {
shader_reset()
if (sprite_exists(self.screenshot)) {
sprite_delete(self.screenshot)
Expand Down
5 changes: 4 additions & 1 deletion RandomForest/objects/oTimeCounter/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ self.default_font = font_add("glasstown.ttf", 12, true, false, 32, 128)
self.may_count = false

// time
self.time_counter = 0
self.time_counter = 0

// secret opportunity
self.timer_drawing_enabled = true
4 changes: 4 additions & 0 deletions RandomForest/objects/oTimeCounter/Draw_0.gml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if (not self.timer_drawing_enabled) {
return
}

// set position on the screen
self.x = 480 - 12 - 20 // magic
self.y = 10
Expand Down
4 changes: 4 additions & 0 deletions RandomForest/objects/oTimeCounter/Step_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ if (keyboard_check_pressed(vk_anykey)) {
self.may_count = true // timer starts after any player response
}

if (keyboard_check_pressed(ord("T"))) {
self.timer_drawing_enabled = !self.timer_drawing_enabled
}

if (self.may_count) {
self.time_counter += 1
}
3 changes: 2 additions & 1 deletion RandomForest/objects/oTraining/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ self.default_font_20 = font_add("glasstown.ttf", 20, true, false, 32, 128)
self.arrow_keys_text = " - Движение персонажа"
self.x_key_text = " - Атака / Возврат меча"
self.c_key_text = " - Бросок меча / Телепорт"
self.fullscreen_text = " - Полноэкранный режим"
self.continue_text = "Для продолжения нажмите любую клавишу"

// size constants
Expand All @@ -20,7 +21,7 @@ self.key_height = self.key_scale * sprite_get_height(sKeyX)
self.room_center_x = room_width / 2
self.room_center_y = room_height / 2
self.start_x = self.room_center_x - 130
self.start_y = self.room_center_y - 70
self.start_y = self.room_center_y - 85

// alpha settings
self.text_alpha = 0.9
Expand Down
10 changes: 10 additions & 0 deletions RandomForest/objects/oTraining/Draw_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ var c_key_start_x = x_key_start_x
var c_key_start_y = x_key_start_y + (self.key_height + self.key_shift) + self.line_interval
draw_sprite_ext(sKeyC, 0, c_key_start_x, c_key_start_y, self.key_scale, self.key_scale, 0, c_white, self.sprite_alpha)

// draw F key (fullscreen)
var f_key_start_x = c_key_start_x
var f_key_start_y = c_key_start_y + (self.key_height + self.key_shift) + self.line_interval
draw_sprite_ext(sKeyF, 0, f_key_start_x, f_key_start_y, self.key_scale, self.key_scale, 0, c_white, self.sprite_alpha)


// set up font for controls
draw_set_halign(fa_left)
Expand All @@ -49,6 +54,11 @@ var c_key_text_x = arrow_keys_text_x
var c_key_text_y = c_key_start_y + self.magic_shift
draw_text_color(c_key_text_x, c_key_text_y, self.c_key_text, c_white, c_white, c_white, c_white, self.text_alpha)

// type F key text (fullscreen)
var f_key_text_x = arrow_keys_text_x
var f_key_text_y = f_key_start_y + self.magic_shift
draw_text_color(f_key_text_x, f_key_text_y, self.fullscreen_text, c_white, c_white, c_white, c_white, self.text_alpha)


// set up font for continue
draw_set_halign(fa_middle)
Expand Down
Loading

0 comments on commit 629b517

Please sign in to comment.