Skip to content

Commit

Permalink
feat: GameMaker demo
Browse files Browse the repository at this point in the history
  • Loading branch information
zLulus committed Aug 4, 2024
1 parent 443c206 commit 54527f6
Show file tree
Hide file tree
Showing 37 changed files with 754 additions and 22 deletions.
9 changes: 8 additions & 1 deletion GameMaker/GameMakerDemo/GameMakerDemo.yyp

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

23 changes: 13 additions & 10 deletions GameMaker/GameMakerDemo/objects/CloseMenuDialogButton/Draw_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,28 @@ draw_self()
draw_set_font(DefaultFont)
draw_set_color(DefaultShader)

//var font = DefaultFont.text_width; // 或者使用你自己的字体
//Sprite set as left-top
//var font = DefaultFont.text_width;
var font_size=font_get_size(DefaultFont)
// 计算文字宽度
// get font width
var text_width_pixels = string_width(text);
var text_width=text_width_pixels/font_size;
var screen_width = sprite_width*image_xscale;
var text_x = (screen_width / 2) - (text_width / 2);
var text_y = sprite_height*image_yscale / 2;
//var screen_width = 794*image_xscale;
var text_x = x+ (screen_width - text_width);
var text_y = y+sprite_height*image_yscale;
//var text_y = 268*image_yscale / 2;
show_debug_message(text_x);
show_debug_message(text_y);
draw_text(text_x,text_y,text)


//Room居中
//// 计算文字宽度
//Center in Room
//// get font width
//var text_width = string_width(text);
//// 获取屏幕宽度(或你想让文字居中的区域宽度)
//var screen_width = room_width; // 如果你想让文字在整个房间宽度内居中
//// 计算文字的X坐标,使其水平居中
//// get screen width
//var screen_width = room_width;
//// horizontal centering
//var text_x = (screen_width / 2) - (text_width / 2);
//// 设置文字的Y坐标,这里我们简单地设置它为屏幕高度的一半
//// vehicle centering
//var text_y = room_height / 2;
3 changes: 3 additions & 0 deletions GameMaker/GameMakerDemo/objects/DatabaseButton/Create_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// @description 在此处插入描述
// 你可以在此编辑器中写入代码
text=Translation("DatabaseButtonKey")
40 changes: 40 additions & 0 deletions GameMaker/GameMakerDemo/objects/DatabaseButton/DatabaseButton.yy

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

6 changes: 6 additions & 0 deletions GameMaker/GameMakerDemo/objects/DatabaseButton/Draw_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// @description 在此处插入描述
// 你可以在此编辑器中写入代码
draw_self()
draw_set_font(DefaultFont)
draw_set_color(DefaultShader)
draw_text(x,y,text)
2 changes: 2 additions & 0 deletions GameMaker/GameMakerDemo/objects/DatabaseButton/Mouse_4.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// @description 在此处插入描述
// 你可以在此编辑器中写入代码
4 changes: 2 additions & 2 deletions GameMaker/GameMakerDemo/objects/DialogBox/DialogBox.yy

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// @description 在此处插入描述
// 你可以在此编辑器中写入代码
// 获取屏幕中心位置
var center_x = room_width / 2;
var center_y = room_height / 2;

// 创建文本显示实例
var inst = instance_create_layer(center_x, center_y,"Instances", Text,
{
//可以在这里直接给Object的text及其其他属性赋值
//可以在Draw事件中赋值
//可以给inst的属性赋值
text:"Hello world"
});

// 设置实例的参数
//inst.text = "Hello, World!";
//inst.font = font_SpecialFont; // 假设你已经创建了一个名为 font_SpecialFont 的字体
//inst.color = c_red;
//inst.scale = 2.0;

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

12 changes: 12 additions & 0 deletions GameMaker/GameMakerDemo/objects/ProcessBar/Draw_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// @description 在此处插入描述
// 你可以在此编辑器中写入代码
// Draw event
// 绘制背景
//draw_sprite_ext(spr_Progress_Bar_Background, 0, x, y, 1, 1, 0, c_white, 1);

// 计算填充宽度
var full_width= sprite_width*image_xscale;
var fill_width = (current_progress / max_progress) *full_width;

// 绘制填充部分
draw_sprite_ext(BlueProcessBarSprite, 0, x, y, fill_width / full_width, 1, 0, c_white, 1);
42 changes: 42 additions & 0 deletions GameMaker/GameMakerDemo/objects/ProcessBar/ProcessBar.yy

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

14 changes: 14 additions & 0 deletions GameMaker/GameMakerDemo/objects/ProcessBar/Step_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// @description 在此处插入描述
// 你可以在此编辑器中写入代码
// Step event
//if (keyboard_check(vk_space)) { // 按下空格键时增加进度
current_progress += 1;
if (current_progress > max_progress) {
current_progress = max_progress;
}
//}

// 重置进度
if (keyboard_check(vk_enter)) { // 按下 R 键时重置进度
current_progress = 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// @description 在此处插入描述
// 你可以在此编辑器中写入代码
text="Set Window Size"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// @description 在此处插入描述
// 你可以在此编辑器中写入代码
draw_self()
draw_set_font(DefaultFont)
draw_set_color(DefaultShader)
draw_text(x,y,text)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// @description 在此处插入描述
// 你可以在此编辑器中写入代码
window_set_size(1000,1000)

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

6 changes: 6 additions & 0 deletions GameMaker/GameMakerDemo/objects/Text/Draw_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// @description 在此处插入描述
// 你可以在此编辑器中写入代码
draw_self()
draw_set_font(DefaultFont)
draw_set_color(DefaultShader)
draw_text(x,y,text)
38 changes: 38 additions & 0 deletions GameMaker/GameMakerDemo/objects/Text/Text.yy

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

Loading

0 comments on commit 54527f6

Please sign in to comment.