From fe23cb56860c14ac53496d072996d2391112aaaf Mon Sep 17 00:00:00 2001 From: Demonmasterlqx <183842220@qq.com> Date: Thu, 14 Nov 2024 19:35:42 +0800 Subject: [PATCH 1/2] add src --- .../src/antity/antity_memory.mbt" | 431 ++++++++++++++++++ .../src/antity/moon.pkg.json" | 7 + .../src/antity/struct.mbt" | 138 ++++++ .../src/antity/struct_trait.mbt" | 286 ++++++++++++ .../src/bitset/bitset.mbt" | 78 ++++ .../src/bitset/moon.pkg.json" | 1 + .../src/interface/gaming.mbt" | 356 +++++++++++++++ .../src/interface/interface_control.mbt" | 11 + .../src/interface/moon.pkg.json" | 7 + .../src/moon.pkg.json" | 20 + .../src/time_cnt/moon.pkg.json" | 5 + .../src/time_cnt/timer.mbt" | 9 + .../src/top.mbt" | 15 + 13 files changed, 1364 insertions(+) create mode 100644 "teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/antity_memory.mbt" create mode 100644 "teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/moon.pkg.json" create mode 100644 "teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/struct.mbt" create mode 100644 "teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/struct_trait.mbt" create mode 100644 "teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/bitset/bitset.mbt" create mode 100644 "teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/bitset/moon.pkg.json" create mode 100644 "teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/interface/gaming.mbt" create mode 100644 "teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/interface/interface_control.mbt" create mode 100644 "teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/interface/moon.pkg.json" create mode 100644 "teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/moon.pkg.json" create mode 100644 "teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/time_cnt/moon.pkg.json" create mode 100644 "teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/time_cnt/timer.mbt" create mode 100644 "teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/top.mbt" diff --git "a/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/antity_memory.mbt" "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/antity_memory.mbt" new file mode 100644 index 0000000..76b97c5 --- /dev/null +++ "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/antity_memory.mbt" @@ -0,0 +1,431 @@ +let low_y:Int=150 + +//底部状态栏 +//HP显示 +// pub fn hp()->Frame_effects_{ +// {begin:0, +// xlen:12, +// ylen:10, +// sprite:[ +// @bitset.Bitset::new@bitset.Bitset::new(2,"101000101000101010100000101000101000101010101010101000101000101000001010101000101000101000001010101010101000101010101010101010101000101010101000101000101000101000000000101000101000101000000000101000101000101000000000101000101000101000000000") +// ], +// back_ground:[ +// @bitset.Bitset::new(1,"001001000011001001000000001001000000001001000000000001000000000001000001001001001111001001001111001001001111001001001111") +// ]} +// } +// pub fn num0()->Frame_effects_{ +// {begin:0, +// xlen:6, +// ylen:10, +// sprite:[ +// @bitset.Bitset::new(2,"000001010000000101010100010100000101010100000101010100000101010100000101010100000101000101010100000001010000000000000000") +// ], +// back_ground:[ +// @bitset.Bitset::new(1,"110011100001000000000000000000000000000000100001110011111111") +// ]} +// } +// pub fn num1()->Frame_effects_{ +// {begin:0, +// xlen:6, +// ylen:10, +// sprite:[ +// @bitset.Bitset::new(2,"000001010000000101010000010101010000010001010000000001010000000001010000000001010000010101010101010101010101000000000000") +// ], +// back_ground:[ +// @bitset.Bitset::new(1,"110011100011000011010011110011110011110011000000000000111111") +// ]} +// } +// pub fn num2()->Frame_effects_{ +// {begin:0, +// xlen:6, +// ylen:10, +// sprite:[ +// @bitset.Bitset::new(2,"000001010000000101010100010100000101010100000101000000010100000001010000000101000000010101010101010101010101000000000000") +// ], +// back_ground:[ +// @bitset.Bitset::new(1,"110011100001001100001100111001110011100111000000000000111111") +// ]} +// } +// pub fn num3()->Frame_effects_{ +// {begin:0, +// xlen:6, +// ylen:10, +// sprite:[ +// @bitset.Bitset::new(2,"000101010000010101010100010000000101000000000101000101010100000000000101000000000101010101010101000101010100000000000000") +// ], +// back_ground:[ +// @bitset.Bitset::new(1,"100011000001011100111100100001111100111100000000100001111111") +// ]} +// } +// pub fn num4()->Frame_effects_{ +// {begin:0, +// xlen:6, +// ylen:10, +// sprite:[ +// @bitset.Bitset::new(2,"000000010100000001010100000100010100000100010100010000010100010000010101010101010101000000010100000000010100000000000000") +// ], +// back_ground:[ +// @bitset.Bitset::new(1,"111001110001100001100001000001000000000000111001111001111111") +// ]} +// } +// pub fn num5()->Frame_effects_{ +// {begin:0, +// xlen:6, +// ylen:10, +// sprite:[ +// @bitset.Bitset::new(2,"010101010101010101010101010000000000010101000000000101010100000000010101000000000101000000000101010101010100000000000000") +// ], +// back_ground:[ +// @bitset.Bitset::new(1,"000000000000011111000111100001111000111100111100000001111111") +// ]} +// } +// pub fn num6()->Frame_effects_{ +// {begin:0, +// xlen:6, +// ylen:10, +// sprite:[ +// @bitset.Bitset::new(2,"000001010100000101010100010100000000010100000000010101010101010100000101010100000101010101010101000101010100000000000000") +// ], +// back_ground:[ +// @bitset.Bitset::new(1,"110001100001001111001111000000000000000000000000100001111111") +// ]} +// } +// pub fn num7()->Frame_effects_{ +// {begin:0, +// xlen:6, +// ylen:10, +// sprite:[ +// @bitset.Bitset::new(2,"010101010100010101010100000000010100000000010100000000010100000000010100000001010000000101000000010100000000000000000000") +// ], +// back_ground:[ +// @bitset.Bitset::new(1,"000001000001111001111001111001111001110011100111001111111111") +// ]} +// } +// pub fn num8()->Frame_effects_{ +// {begin:0, +// xlen:6, +// ylen:10, +// sprite:[ +// @bitset.Bitset::new(2,"000101010100000100000100010000000001010000000001000100000100000101010100010000000001010000000001000101010100000000000000") +// ], +// back_ground:[ +// @bitset.Bitset::new(1,"100001100001000000000000100001100001000000000000100001111111") +// ]} +// } +// pub fn num9()->Frame_effects_{ +// {begin:0, +// xlen:6, +// ylen:10, +// sprite:[ +// @bitset.Bitset::new(2,"000001010101000101010101010100000101010100000101010100000101010101010101000101000101000000000101000000000101000000000101") +// ], +// back_ground:[ +// @bitset.Bitset::new(1,"110011100011000011010011110011110011110011000000000000111111") +// ]} +// } + + + +//特效 + +pub fn player_Plane_effect()->Frame_effects_{ + {begin:0, + xlen:20, + ylen:20, + sprite:[ + @bitset.Bitset::new(2,"00000000000000000011000000000000000000000000000000000000001100000000000000000000000000000000000000110000000000000000000000000000000000000011000000000000000000000000000000000000111111000000000000000000000000000000000011101100000000000000000000000000000000001100110000000000000000000000000000000011101010000000000000000000000000000011111000100001001100000000000000000000000000000101000000101111000000000000000000000100010000000100101011000000000000001110100110100100011111111111000000000011111111111000010111000000001100000000001100000000011000001011000000000000000000000000001110100000111100000000000000000000000000111111000001111100000000000000000000001111010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), + @bitset.Bitset::new(2,"00000000000000000011000000000000000000000000000000000000001100000000000000000000000000000000000000110000000100000000000000000000000000000011000000000000000000000000000000010000111111000000000000000000000000000000000111100101000100000000000000000000000000011100110000000000000000000000000000010100000010110100000100000000000000000000000001000001000101000000000000010000000101011010000101000000000000000000000000111110010100010010111100000000000000011110010001010001100110101100000000000011111111110100000110111111111100000000001101000100110001011100010000110000000000000000001110000010101101000000000000000000010101111101001111110000000000000000000000001101010000000111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), + @bitset.Bitset::new(2,"00000000000000000011000000000000000000000000000000000000001100000000000000000000000000000000000000110100000001000000000000000000000000000111000000000000000000000000000000000000111111000000000000000000000000000001000011011101000000010000000000000000000000001100110001000000000000000000000000000011101010000100000000010000000000000011111000100001001100000000000000000000010000000101000000101101000000000000000000000101010000000100100111000000000000001110100110100100010111011111000000000011110111111000010101110000001100000000001101000001011000001111000000000000000000000000000110100000110100000000000000000000000001111111000001111100000000000000000000011111010000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), + @bitset.Bitset::new(2,"00000000000000001100000000000000000000000100000000000000110000000000000000000000000000000000001100000000000000000000010000000000000000110000000100000000000000000000000101001111011100000000000000000000000000000000011011101011000000010000000000000100000011000010000001000000000000010000000000000010001010000000000000000000000100000000000000000100101111000100000000000000111100100000000000100111010000000000111101011110000100001111111111000000000011110111001110110000000000001100010000000000000101101010000000000000000000000001000000000100001100001101000000000100000000001111010000110000110001000000000001000011011100000000000011010000000000000000000000000000000001000000000000000000000001010001000000000000000000010000000001000000000000000000000000000000000001000000000000000000000000000000000000000000") + ], + back_ground:[ + @bitset.Bitset::new(1,"1111111110111111111111111111101111111111111111111011111111111111111110111111111111111111000111111111111111110001111111111111111100011111111111111110000111111111111110000010101111111111111100111000111111111101011100000111111100000001000000111110000000000111101111101111001100111111111111100011001111111111111000110001111111111100011111111111111111111111111111111111111111111111111111111111111111111111"), + @bitset.Bitset::new(1,"1111111110111111111111111111101111111111111111111011101111111111111110111111111111111011000111111111111111100000101111111111111001011111111111111001110001101111111111110110000111111011100000100111111111111000001000001111111000000010000001111110000001100000001111100100010000011011111111100110000111111111000000100011111111111100011100011111111111111111111111111111111111111111111111111111111111111111"), + @bitset.Bitset::new(1,"1111111110111111111111111111101111111111111111111001110111111111111100111111111111111111000111111111111110110000111011111111111100000111111111111110000001111011111110000000001111111111011100000000111111111100000000000111111100000000000000111110000000000011101111100110001100111111111111100011001111111111110000110001111111111000011110111111111111111111111111111111111111111111111111111111111111111111"), + @bitset.Bitset::new(1,"1111111101111111111101111111011111111111111111101111111111011111111011101111111111100100001111111111111111000000111011111101110110110111111011111110100111111111101111111101000101111111001011111000011111000000101100000111110000000011111101011111100000111111111110111101101100111101111100011011000111110110001111110011111111111111110111111111110010111111111011110111111111111111110111111111111111111111") + ]} +} + +// 玩家飞机正常一般形态 + +pub fn get_fram_entity(num:Int)->Frame_effects{ + if(num==1) {return bullet1_()} + if(num==9) {return bullet9_()} + if(num==2) {return high_explosive_my_()} + if(num==11) {return high_explosive_en_()} + if(num==3) {return player_Plane_1_frame()} + if(num==4) {return small_plane_()} + if(num==5) {return middle_plane_()} + if(num==6) {return high_explosive_cartridge_()} + if(num==7) {return double_cartridge_()} + if(num==8) {return hp_recovery_pack_()} + return double_cartridge_() +} + +// type_ 分配规则 +// 普通子弹_敌人 1 +// 普通子弹_自己 9 +// 高爆子弹_自己 2 +// 高爆子弹_敌人 11 +// 自机 3 +// 敌机小型机 4 +// 敌机中型机_普通子弹版 5 +// 高爆子弹包 6 +// 双倍子弹包 7 +// 血量恢复包 8 +// 激光子弹包 10 + +pub fn player_Plane_1_frame()-> Frame_effects{ + { + xlen:13, + ylen:15, + sprite:@bitset.Bitset::new(2,"000000000000110000000000000000000000001100000000000000000000000011000000000000000000000000110000000000000000000000111111000000000000000000001110110000000000000000000011001100000000000000000011101010110000000000001111100010001011110000001110100010101000101011001111111111100010111111111111000000001110110000000011000000001110101011000000000000000011111111110000000000000011110100011111000000"), + back_ground:@bitset.Bitset::new(1,"111111011111111111101111111111110111111111111011111111111000111111111100011111111110001111111110000011111100000000011100000000000100000000000000111100011110111100000111111110000011111110001000111") + } +} + +pub fn small_plane_()->Frame_effects{ + { + xlen:7, + ylen:9, + sprite:@bitset.Bitset::new(2,"000001000100000010110011100000001011100000000010111000001011001100111000101100111000000010001000000000101110000000000010000000"), + back_ground:@bitset.Bitset::new(1,"110101110000011100001110000100000001000001110000111000011110111") + } +} + +pub fn middle_plane_()->Frame_effects{ + { + xlen:11, + ylen:17, + sprite:@bitset.Bitset::new(2,"00000001000000010000000000000100000001000000000001010000000101000000101110000000101110000000101110001011100000000010111110111110000000000010101110100000001000001011001110000010100010110000001110001011101110001100101110111011101000000010101110001011101000101011100000001011000000111000000000001011001110000000000000101100111000000000000000101110000000000000000000100000000000"), + back_ground:@bitset.Bitset::new(1,"1110111011111100000001110000000011000000000111000000001110000000011110000000101100000000010000000000000000000000000000000100000000011100000000111100000001111000000011111000000111111011111") +} +} + +pub fn small_plane()->Aircraft{{ + type_:4, + pos:Location::new(x=0,y=0,4), + bullet_exit_point:[], + speed:1.3666666666666667, + dir:90, + // frame:small_plane_(), + hp:10} +} + +pub fn middle_plane()->Aircraft{{ + type_:5, + pos:Location::new(x=0,y=0,5), + bullet_exit_point:[Bullet_exit_point::new(4,17,1,95,50)], + speed:0.6666666666666667, + dir:90, + // frame:middle_plane_(), + hp:60} +} + +pub fn middle_plane_high_explode()->Aircraft{{ + type_:5, + pos:Location::new(x=0,y=0,5), + bullet_exit_point:[Bullet_exit_point::new(4,17,11,95,60)], + speed:0.6666666666666667, + dir:90, + // frame:middle_plane_(), + hp:60} +} + +pub fn player_Plane()->Aircraft{{ + type_:3, + pos:Location::new(x=73,y=120,3), + bullet_exit_point:[Bullet_exit_point::new(5,5,9,0,10)], + speed:1.3666666666666667, + dir:180, + // frame:player_Plane_1_frame(), + hp:100 + } +} + +pub fn bullet9_()->Frame_effects{{ + xlen:3, + ylen:3, + sprite:@bitset.Bitset::new(2,"010101010101010101"), + back_ground:@bitset.Bitset::new(1,"000000000")} +} + +pub fn bullet1_()->Frame_effects{{ + xlen:3, + ylen:3, + sprite:@bitset.Bitset::new(2,"111111111111111111"), + back_ground:@bitset.Bitset::new(1,"000000000") + } +} + + +pub fn bullet1()->Bullet{{ + type_:9, + harm:8, + pos:Location::new(9), + dir:270, + speed:1, + // frame:bullet1_() + } +} + +pub fn bullet2()->Bullet{{ + type_:1, + harm:8, + pos:Location::new(1), + dir:90, + speed:1, + // frame:bullet2_() + } +} + +pub fn high_explosive_en_()->Frame_effects{{ + xlen:3, + ylen:3, + sprite:@bitset.Bitset::new(2,"101110110111101110"), + back_ground:@bitset.Bitset::new(1,"000000000")} +} + +pub fn high_explosive_my_()->Frame_effects{{ + xlen:3, + ylen:3, + sprite:@bitset.Bitset::new(2,"111011100110111011"), + back_ground:@bitset.Bitset::new(1,"000000000")} +} + +pub fn high_explosive_my()->Bullet{{ + type_:2, + harm:25, + pos:Location::new(2), + dir:270, + speed:1, + // frame:high_explosive_my_() + } +} + +pub fn high_explosive_en()->Bullet{{ + type_:11, + harm:30, + pos:Location::new(11), + dir:90, + speed:1, + // frame:high_explosive_en_() + } +} + +pub fn high_explosive_cartridge_()->Frame_effects{{ + xlen:8, + ylen:8, + sprite:@bitset.Bitset::new(2,"10100000000010101010111111111010101000010100101010100001010010101010000101001010101000010100101010101111111110101010000000001010"), + back_ground:@bitset.Bitset::new(1,"0011110000000000000000000000000000000000000000000000000000111100")} +} + +pub fn high_explosive_cartridge()->Cartridge{{ + type_:6, + pos:Location::new(6), + speed:0.5, + dir:90, + effect:0, + // frame:high_explosive_cartridge_() + } +} + +pub fn hp_recovery_pack()->Cartridge{{ + type_:8, + pos:Location::new(8), + speed:0.5, + dir:90, + effect:50, + // frame:hp_recovery_pack_() + } +} + +pub fn hp_recovery_pack_()->Frame_effects{{ + xlen:8, + ylen:8, + sprite:@bitset.Bitset::new(2,"00111100001111001110101111101011111001101001101111011001011001110011101010101100001101101001110000001101011100000000001111000000"), + back_ground:@bitset.Bitset::new(1,"1001100100000000000000000000000010000001100000011100001111100111") +}} + +pub fn double_cartridge()->Cartridge{{ + type_:7, + pos:Location::new(7), + speed:0.5, + dir:90, + effect:0, + // frame:double_cartridge_() + } +} + +pub fn double_cartridge_()->Frame_effects{{ + xlen:8, + ylen:8, + sprite:@bitset.Bitset::new(2,"10100000000010101010010101011010101011101011101010101110101110101010111010111010101011101011101010100101010110101010000000001010"), + back_ground:@bitset.Bitset::new(1,"0011110000000000000000000000000000000000000000000000000000111100")} +} + +// pub let bullet:Map[Int,Bullet]={9:bullet1,1:bullet2,2:high_explosive_my,11:high_explosive_en} +// pub let plans:Map[Int,Aircraft]={3:player_Plane,4:small_plane,5:middle_plane} +// pub let cartridge:Map[Int,Cartridge]={6:high_explosive_cartridge,8:hp_recovery_pack,7:double_cartridge} +// pub let cart_bullet:Map[Int,Int]={ +// 6:2 +// } +// pub let default_bullet:Map[Int,Array[Bullet_exit_point]]={ +// 3:[Bullet_exit_point::new(5,5,9,0,10)], +// 5:[Bullet_exit_point::new(4,17,1,0,90)], +// 6:[Bullet_exit_point::new(5,5,2,0,10,limit=20)], +// 7:[Bullet_exit_point::new(2,8,9,0,10,limit=30),Bullet_exit_point::new(9,8,9,0,10,limit=30)], +// 4:[] +// } + +pub fn bullet(n:Int)->Bullet{ + match n{ + 9=>bullet1() + 1=>bullet2() + 2=>high_explosive_my() + 11=>high_explosive_en() + _=>bullet1() + } +} +pub fn plans(n:Int)->Aircraft{ + match n{ + 3=>player_Plane() + 4=>small_plane() + 5=>middle_plane() + 12=>middle_plane_high_explode() + _=>small_plane() + } +} + +pub fn cartridge(n:Int)->Cartridge{ + match n{ + 6=>high_explosive_cartridge() + 8=>hp_recovery_pack() + 7=>double_cartridge() + _=>double_cartridge() + } +} + +pub fn default_bullet(n:Int)->FixedArray[Bullet_exit_point]{ + match n{ + 3 => return [Bullet_exit_point::new(5,5,9,0,10)] + 5 => return [Bullet_exit_point::new(4,17,1,0,90)] + 6 => [Bullet_exit_point::new(5,5,2,0,10,limit=20)] + 7 => [Bullet_exit_point::new(2,8,9,0,10,limit=30),Bullet_exit_point::new(9,8,9,0,10,limit=30)] + 12 => [Bullet_exit_point::new(4,17,11,0,90)] + _=> [Bullet_exit_point::new(5,5,9,0,10)] + } +} + +pub fn get_score(n:Int)->Int{ + match n{ + 4 => return 10 + 5 => return 50 + 6 => 30 + 7 => 25 + _ => 0 + } +} + +//pub var of music +//音乐用途tones数组 diff --git "a/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/moon.pkg.json" "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/moon.pkg.json" new file mode 100644 index 0000000..01d97f9 --- /dev/null +++ "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/moon.pkg.json" @@ -0,0 +1,7 @@ +{ + "import": [ + "moonbitlang/wasm4", + "GAME/time_cnt", + "GAME/bitset" + ] +} \ No newline at end of file diff --git "a/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/struct.mbt" "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/struct.mbt" new file mode 100644 index 0000000..6354585 --- /dev/null +++ "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/struct.mbt" @@ -0,0 +1,138 @@ +pub struct Location{ + mut x:Double + mut y:Double + // mut newx:Double + // mut newy:Double + type_:UInt +//用于记录实体的位置 +} + +// struct Sprite_parameter{ +// x:UInt +// y:UInt +// //相对于基准像素的偏移量 +// color:UInt +// } + +// pub struct Frame{ +// mut x:Int +// mut y:Int +// //代表左上角的基准像素 +// sprite:Array[Sprite_parameter] +// //这个代表一帧!! +// } + +pub struct Frame_time_config{ + mut begin:Int + mut end:Int +} + +pub struct Frame_effects{ + xlen:UInt + ylen:UInt + sprite:@bitset.Bitset + back_ground:@bitset.Bitset +} + +pub struct Frame_effects_{ + mut begin:UInt + xlen:UInt + ylen:UInt + sprite:Array[@bitset.Bitset] + back_ground:Array[@bitset.Bitset] +} + +// pub struct Frame_effects_{ +// mut begin_time:UInt64 +// mut end_time:UInt64 +// mut x:UInt +// mut y:UInt +// sprite:Array[Frame] +// time_management:Array[Frame_time_config] +// //time_management与sprite的长度一致,time_management用于控制sprite的每一帧显示时间 +// } + +pub struct ToneParams { + frequency: (UInt, UInt) + adsr: @wasm4.ADSR + volume: @wasm4.ADSRVolume + channel: @wasm4.ToneFlag +} + +pub struct Sound_effects{ + //具体实现待研究QWQ + effects:Array[ToneParams] +} +pub struct ToneForPub { + tone:ToneParams + startfps:UInt +} +// pub struct Effects{ +// frame:Frame_effects_ +// sound:Array[ToneParams] +// } + +pub struct Bullet{ + type_:Int + harm:Double + pos:Location + dir:Double + speed:Double + // frame:Frame_effects +} + +// pub struct Laser{ +// type_:UInt +// pos:Location +// //表示激光最顶点的位置 +// dir:UInt +// //激光方向 +// harm:UInt +// // warming:Frame_effects + +// } +//激光应当还有一个方向改变函数!!! + +pub struct Bullet_exit_point{ + x:Int + y:Int + type_:Int + mut last_shoot:Int + shoot_speed:Int + mut limit:Int +} + +pub struct Aircraft{ + type_:Int + pos:Location + mut speed:Double + mut dir:Double + // frame:Frame_effects + mut hp:Double + bullet_exit_point:Array[Bullet_exit_point] +} +//方向先不管,是个角度,0度方向与x轴正方向平行,顺时针转 +//weapon 1是单发 2是双发 +//speed 是每帧速度 +pub struct Cartridge{ + type_:Int + pos:Location + mut speed:Double + dir:Double + effect:Double + // frame:Frame_effects +} + +// type_ 分配规则 +// 普通子弹_敌人 1 +// 普通子弹_自己 9 +// 高爆子弹_自己 2 +// 高爆子弹_敌人 11 +// 自机 3 +// 敌机小型机 4 +// 敌机中型机_普通子弹版 5 +// 敌机中型机_高爆子弹版 12 +// 高爆子弹包 6 +// 双倍子弹包 7 +// 血量恢复包 8 +// 激光子弹包 10 \ No newline at end of file diff --git "a/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/struct_trait.mbt" "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/struct_trait.mbt" new file mode 100644 index 0000000..944488c --- /dev/null +++ "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/antity/struct_trait.mbt" @@ -0,0 +1,286 @@ +// pub trait Strike{ +// is_strike(Self,Self)->Bool +// } + +// pub trait Updata_pos{ +// updata_pos(Self)->Unit +// } + +// pub trait Get_new_pos{ +// get_new_pos(Self)->Unit +// } +// pub trait Setmusic{ +// setup_tone_params() -> Array[ToneParams] +// } + +pub let scores:Ref[Int]=Ref::new(0); + +pub fn get_index(x:UInt,y:UInt)->UInt{ + y*160+x +} + +//造成伤害####################################################################################################################################### + +//造成伤害####################################################################################################################################### + +//展示函数############################################# + +pub fn show(self:Frame_effects,x:Int,y:Int)->Unit{ + let mut index=0 + let mut posx=x + let mut posy=y + for i=0U;i=160||posx<0||posy<0||posy>low_y).not()){ + @wasm4.set_frame_buffer(get_index(posx.reinterpret_as_uint(),posy.reinterpret_as_uint()),self.sprite[index]+1) + } + index=index+1 + posx=posx+1 + } + posx=x + posy=posy+1 + } +} + +pub fn showp(self:Frame_effects_,x:Int,y:Int,t:Int)->Unit{ + let mut index=0 + let mut posx=x + let mut posy=y + for i=0U;i=160||posx<0||posy<0||posy>low_y).not()){ + @wasm4.set_frame_buffer(get_index(posx.reinterpret_as_uint(),posy.reinterpret_as_uint()),self.sprite[t][index]+1) + } + index=index+1 + posx=posx+1 + } + posx=x + posy=posy+1 + } +} + + +pub fn print(self:Aircraft)->Unit{ + get_fram_entity(self.type_).show(self.pos.x.to_int(),self.pos.y.to_int()) +} + +pub fn print(self:Bullet)->Unit{ + get_fram_entity(self.type_).show(self.pos.x.to_int(),self.pos.y.to_int()) +} + +// pub fn print(self:Laser)->Unit{ +// // get_fram_entity(self.type_).show(self.pos.x.to_int(),self.pos.y.to_int()) +// } + +pub fn print(self:Cartridge)->Unit{ + get_fram_entity(self.type_).show(self.pos.x.to_int(),self.pos.y.to_int()) +} + +//展示函数############################################# + +//构造函数############################################# +pub fn Location::new(~x:Double=0,~y:Double=0,type_:UInt)->Location{ + {x,y,type_} +} + +pub fn Bullet_exit_point::new(x:Int,y:Int,type_:Int,last_shoot:Int,shoot_speed:Int,~limit:Int=-1)->Bullet_exit_point{ + {x,y,type_,last_shoot,shoot_speed,limit} +} +//构造函数############################################# + +//更新位置############################################# +// let eps:Double=0.000000001 +pub fn Aircraft::update_pos(self:Aircraft)->Unit{ + let x=self.pos.x + let y=self.pos.y + self.pos.x=self.pos.x+self.speed*@math.cos(self.dir/180*@math.PI) + self.pos.y=self.pos.y+self.speed*@math.sin(self.dir/180*@math.PI) + if self.type_==3{ + if(self.is_out_partly()){ + self.pos.x=x + self.pos.y=y + } + } +} + +pub fn Bullet::update_pos(self:Bullet)->Unit{ + self.pos.x=self.pos.x+self.speed*@math.cos(self.dir/180*@math.PI) + self.pos.y=self.pos.y+self.speed*@math.sin(self.dir/180*@math.PI) +} + +pub fn Cartridge::update_pos(self:Cartridge)->Unit{ + self.pos.x=self.pos.x+self.speed*@math.cos(self.dir/180*@math.PI) + self.pos.y=self.pos.y+self.speed*@math.sin(self.dir/180*@math.PI) +} +//更新位置############################################# + +//检测是否出界######################################### +pub fn Aircraft::is_out_partly(self:Aircraft)->Bool{ + let xl=self.pos.x.to_int()+get_fram_entity(self.type_).xlen.reinterpret_as_int()-1 + let yl=self.pos.y.to_int()+get_fram_entity(self.type_).ylen.reinterpret_as_int()-1 + let x=self.pos.x + let y=self.pos.y + if(((x<160&&xl>=160)||(y>low_y.to_double()&&yl>=low_y)||(x<0&&xl>=0)||(y<0&&yl>=0))||self.is_out_all()) {true} + else {false} +} + +pub fn Aircraft::is_out_all(self:Aircraft)->Bool{ + let xl=self.pos.x.to_int()+get_fram_entity(self.type_).xlen.reinterpret_as_int()-1 + let yl=self.pos.y.to_int()+get_fram_entity(self.type_).ylen.reinterpret_as_int()-1 + let x=self.pos.x.to_int() + let y=self.pos.y.to_int() + if((x>=160||xl<0)||(y<0||yl>=low_y)) {true} + else {false} +} + + +pub fn Bullet::is_out_all(self:Bullet)->Bool{ + let xl=self.pos.x.to_int()+get_fram_entity(self.type_).xlen.reinterpret_as_int()-1 + let yl=self.pos.y.to_int()+get_fram_entity(self.type_).ylen.reinterpret_as_int()-1 + let x=self.pos.x.to_int() + let y=self.pos.y.to_int() + if((x>=160||xl<0)||(y<0||yl>=low_y)) {true} + else {false} +} + +pub fn Cartridge::is_out_all(self:Cartridge)->Bool{ + let xl=self.pos.x.to_int()+get_fram_entity(self.type_).xlen.reinterpret_as_int()-1 + let yl=self.pos.y.to_int()+get_fram_entity(self.type_).ylen.reinterpret_as_int()-1 + let x=self.pos.x.to_int() + let y=self.pos.y.to_int() + if((x>=160||xl<0)||(y<0||yl>=low_y)) {true} + else {false} +} + +pub fn Cartridge::is_out_partly(self:Cartridge)->Bool{ + let xl=self.pos.x.to_int()+get_fram_entity(self.type_).xlen.reinterpret_as_int()-1 + let yl=self.pos.y.to_int()+get_fram_entity(self.type_).ylen.reinterpret_as_int()-1 + let x=self.pos.x + let y=self.pos.y + if(((x<160&&xl>=160)||(y>low_y.to_double()&&yl>=low_y)||(x<0&&xl>=0)||(y<0&&yl>=0))||self.is_out_all()) {true} + else {false} +} + +//检测是否出界######################################### + +//判断死亡######################################################################################## + +pub fn die(self:Aircraft)->Bool{ + self.hp<0.0000001 +} + +//判断死亡######################################################################################## + +//检测撞击################################################################################# + +pub fn get_ratio_en()->Double{ + return (1.0+scores.val.to_double()*0.0008) +} + +pub fn get_ratio_my()->Double{ + return (1.0+scores.val.to_double()*0.0004) +} + +pub fn crash(self:Bullet,obj:Aircraft)->Bool{ + let mut xs:Int=0 + let mut ys:Int=0 + let mut xo:Int=0 + let mut yo:Int=0 + let mut ans=false + let selff=get_fram_entity(self.type_) + let objj=get_fram_entity(obj.type_) + for i=selff.sprite.length()-1;i>=0&&ans.not();i=i-1{ + xs=i%selff.xlen.reinterpret_as_int()+self.pos.x.to_int() + ys=i/selff.xlen.reinterpret_as_int()+self.pos.y.to_int() + for j=objj.sprite.length()-1;j>=0&&ans.not();j=j-1{ + xo=j%objj.xlen.reinterpret_as_int()+obj.pos.x.to_int() + yo=j%objj.ylen.reinterpret_as_int()+obj.pos.y.to_int() + if(xs==xo&&yo==ys) {ans=true} + } + } + if(ans){ + if(self.type_==1||self.type_==11){ + obj.hp=obj.hp-self.harm*get_ratio_en(); + } + else if(self.type_==2||self.type_==9){obj.hp=obj.hp-self.harm*get_ratio_my()} + } + ans +} + +pub fn crash(self:Aircraft,obj:Aircraft)->Bool{ + let mut xs:Int=0 + let mut ys:Int=0 + let mut xo:Int=0 + let mut yo:Int=0 + let mut ans=false + let selff=get_fram_entity(self.type_) + let objj=get_fram_entity(obj.type_) + for i=selff.sprite.length()-1;i>=0&&ans.not();i=i-1{ + xs=i%selff.xlen.reinterpret_as_int()+self.pos.x.to_int() + ys=i/selff.xlen.reinterpret_as_int()+self.pos.y.to_int() + for j=objj.sprite.length()-1;j>=0&&ans.not();j=j-1{ + xo=j%objj.xlen.reinterpret_as_int()+obj.pos.x.to_int() + yo=j%objj.ylen.reinterpret_as_int()+obj.pos.y.to_int() + if(xs==xo&&yo==ys) {ans=true} + } + } + if(ans){ + obj.hp=0 + } + ans +} + +pub fn crash(self:Cartridge,obj:Aircraft)->Bool{ + let mut xs:Int=0 + let mut ys:Int=0 + let mut xo:Int=0 + let mut yo:Int=0 + let mut ans=false + let selff=get_fram_entity(self.type_) + let objj=get_fram_entity(obj.type_) + for i=selff.sprite.length()-1;i>=0&&ans.not();i=i-1{ + xs=i%selff.xlen.reinterpret_as_int()+self.pos.x.to_int() + ys=i/selff.xlen.reinterpret_as_int()+self.pos.y.to_int() + for j=objj.sprite.length()-1;j>=0&&ans.not();j=j-1{ + xo=j%objj.xlen.reinterpret_as_int()+obj.pos.x.to_int() + yo=j%objj.ylen.reinterpret_as_int()+obj.pos.y.to_int() + if(xs==xo&&yo==ys) {ans=true} + } + } + if(ans){ + self.take_effect(obj) + } + ans +} + +//检测撞击################################################################################# + + +//弹药箱生效函数###################################################################################### + +fn take_effect(self:Cartridge,obj:Aircraft)->Unit{ + if(self.type_==8){ + obj.hp=obj.hp+self.effect + } + else if(self.type_==7||self.type_==6){ + obj.bullet_exit_point.clear(); + let len=default_bullet(self.type_).length() + for i=len-1;i>=0;i=i-1{ + obj.bullet_exit_point.push(default_bullet(self.type_)[i]) + } + } +} + +//弹药箱生效函数###################################################################################### + +//function of music + + +//play_tone的用法如下: +//let toneExample = { +// frequency: (261, 523),//frequency可以自己定义,其他有需求再定义 +// adsr: adsrSTD, +// volume: volumeSTD, +// channel: channelSTD +//};//这里的adsrSTD,volumeSTD,channelSTD是在antity_memory.mbt中定义的标准量 +//play_tone(toneExample) diff --git "a/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/bitset/bitset.mbt" "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/bitset/bitset.mbt" new file mode 100644 index 0000000..e68ef67 --- /dev/null +++ "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/bitset/bitset.mbt" @@ -0,0 +1,78 @@ +let up_bit:Int=32; +pub struct Bitset{ + priv mut bits:FixedArray[UInt] + priv mut top:Int//表示存了多少个pre_size + per_size:Int +} + +pub fn Bitset::length(self:Bitset)->Int{ + self.top +} + +pub fn Bitset::new(per_size:Int,string:String)->Bitset{ + let ans:Bitset={bits:[],top:0,per_size} + let mut block=-1 + let mut move=up_bit + ans.top=string.length()/per_size + ans.bits=FixedArray::make(ans.top,0) + for i in string{ + if(move>=up_bit){ + block=block+1; + move=0; + } + ans.bits[block]=ans.bits[block]|((i.to_int()-'0'.to_int()).reinterpret_as_uint()<UInt{ + let indexx=index*self.per_size + let mut block=indexx/up_bit + let mut move=indexx-block*up_bit + let mut ans:UInt=0; + for i=0;i=up_bit){ + block=block+1; + move=0; + } + ans=ans|(((self.bits[block]>>move)&1)<Unit{ +// // println("Push \{input}") +// let indexx=self.top*self.per_size +// let mut block=indexx/up_bit +// let mut move=indexx-block*up_bit +// // println("\{indexx} \{block} \{move}") +// if(move==0) {self.bits.push(0)} +// for i=0;i=up_bit){ +// block=block+1; +// self.bits.push(0) +// move=0; +// } +// self.bits[block]=(self.bits[block]|(((input>>i)&1)<>i)&1)<Unit{ +// let indexx=index*self.per_size +// let mut block=indexx/up_bit +// let mut move=indexx-block*up_bit +// for i=0;i=up_bit){ +// block=block+1; +// move=0; +// } +// if ((self.bits[block]>>move)&1)==1 {self.bits[block]=self.bits[block]&(-1).reinterpret_as_uint()^(1U<>i)&1)<Unit{ + gaming_logic() + // @antity.player_Plane_1.print() +} +let random:@random.Rand=@random.Rand::new() +let aircraft:Array[@antity.Aircraft]=[] +let bullet:Array[@antity.Bullet]=[] +let bullet_my:Array[@antity.Bullet]=[] +// let laser:Array[@antity.Laser]= +// let a:FixedArray[@antity.Laser]=FixedArray::new(200,) +let cartridge:Array[@antity.Cartridge]=[] +let player_plane:@antity.Aircraft=@antity.player_Plane() +let died:Ref[Bool]=Ref::new(false) +let updated:Ref[Bool]=Ref::new(false) +let player_Plane_effect:@antity.Frame_effects_=@antity.player_Plane_effect() +let score:Ref[Int]=Ref::new(0) +let ttime:Ref[Int]=Ref::new(0) +// let playerHP:String=player_plane.hp.to_string() +// let hpWord:String="HP: " +// let time_gone:Int= @time_cnt.get_time().to_int()/60 +// let time_trans:Double=time_gone.to_double()/60.0 + +fn get_rand()->Double{ + (random.uint(limit =160)).to_float().to_double() +} + +fn gaming_logic()->Unit{ + if(died.val){ + //@wasm4.tone((200,201),@wasm4.ADSR::new(100),@wasm4.ADSRVolume::new(100),@wasm4.ToneFlag::new(channel=Noise,mode=Duty_1_2,pan=Center)); + if(updated.val.not()){ + player_Plane_effect.begin=@time_cnt.get_time()+1 + updated.val=true + } + else if(((@time_cnt.get_time()-player_Plane_effect.begin)/16).reinterpret_as_int()<4){ + @antity.showp(player_Plane_effect,(player_plane.pos.x-3).to_int(),(player_plane.pos.y).to_int(),((@time_cnt.get_time()-player_Plane_effect.begin)/16).reinterpret_as_int()); + } + else{ + game_over() + return; + //Game Over + } + } + else{ + @antity.scores.val=score.val + // @wasm4.trace(@antity.get_ratio().to_string()) + ttime.val=@time_cnt.get_time().reinterpret_as_int() + //get_next_pos################################################################################################################ + //self_plane_update_pos + if (button_state.val.button_down||button_state.val.button_up||button_state.val.button_left||button_state.val.button_right)&&(button_state.val.button_down&&button_state.val.button_up&&button_state.val.button_left&&button_state.val.button_right).not()&&((button_state.val.button_down&&button_state.val.button_up)&&button_state.val.button_left.not()&&button_state.val.button_right.not()).not()&&(button_state.val.button_down.not()&&button_state.val.button_up.not()&&(button_state.val.button_left&&button_state.val.button_right)).not(){ + update_self() + } + for i=aircraft.length()-1;i>=0;i=i-1{ + aircraft[i].update_pos() + } + for i=bullet_my.length()-1;i>=0;i=i-1{ + bullet_my[i].update_pos() + } + for i=bullet.length()-1;i>=0;i=i-1{ + bullet[i].update_pos() + } + for i=cartridge.length()-1;i>=0;i=i-1{ + cartridge[i].update_pos() + } + // for i=laser.length();i>=0;i=i-1{ + // //waiting + // } + // //判断碰撞#################################################################################################################### + // for i=0;i=0;i=i-1{ + if(bullet[i].crash(player_plane)){ + bullet_crashed.push(i) + @wasm4.tone((200,401),@wasm4.ADSR::new(10),@wasm4.ADSRVolume::new(100),@wasm4.ToneFlag::new(channel=Noise,mode=Duty_1_2,pan=Center)); + } + } + for i=bullet_my.length()-1;i>=0;i=i-1{ + for j=aircraft.length()-1;j>=0;j=j-1{ + if(bullet_my[i].crash(aircraft[j])){ + bullet_crashed_my.push(i) + @wasm4.tone((200,401),@wasm4.ADSR::new(10),@wasm4.ADSRVolume::new(100),@wasm4.ToneFlag::new(channel=Noise,mode=Duty_1_2,pan=Center)); + } + } + } + for i=aircraft.length()-1;i>=0;i=i-1{ + if(aircraft[i].crash(player_plane)){ + died.val=true + aircraft.remove(i) |> ignore + } + } + for i=cartridge.length()-1;i>=0;i=i-1{ + if(cartridge[i].crash(player_plane)){ + score.val=score.val+@antity.get_score(cartridge[i].type_) + cartridge.remove(i)|> ignore + } + } + // for i=0;i=0;i=i-1{ + bullet_my.remove(bullet_crashed_my[i]) |> ignore + //加入子弹爆炸特效 + } + for i=bullet_crashed.length()-1;i>=0;i=i-1{ + bullet.remove(bullet_crashed[i]) |> ignore + //加入子弹爆炸特效 + } + for i=aircraft.length()-1;i>=0;i=i-1{ + if(aircraft[i].is_out_all()){ + aircraft.remove(i)|> ignore + } + else if(aircraft[i].die()){ + score.val=score.val+@antity.get_score(aircraft[i].type_) + aircraft.remove(i)|> ignore + //特效 + } + } + for i=bullet.length()-1;i>=0;i=i-1{ + if(bullet[i].is_out_all()){ + bullet.remove(i)|> ignore + } + } + for i=bullet_my.length()-1;i>=0;i=i-1{ + if(bullet_my[i].is_out_all()){ + bullet_my.remove(i)|> ignore + } + } + for i=cartridge.length()-1;i>=0;i=i-1{ + if(cartridge[i].is_out_all()){ + cartridge.remove(i)|> ignore + } + } + // for i=laser.length()-1;i>=0;i=i-1{ + // //waiting + // } + + //生成############################################################################################################## + + + generate_plane() + if(random.uint(limit =1000)<=3){ + generate_cartridge() + } + for i=aircraft.length()-1;i>=0;i=i-1{ + shoot(aircraft[i]) + } + shoot(player_plane) + //子弹袋生成!!! + + //临时参数显示 + // @wasm4.text(bullet_my.length().to_string(),0,0) + // @wasm4.text(bullet.length().to_string(),0,8) + // @wasm4.text(aircraft.length().to_string(),0,16) + // @wasm4.text(player_plane.hp.to_string(),0,24) + // @wasm4.text(bullet_crashed_my.length().to_string(),0,32) + // @wasm4.text(bullet_crashed.length().to_string(),0,40) + // @wasm4.text(ttime.val.to_string(),0,0) + + } + //打印############################################################################################################## + for i=bullet.length()-1;i>=0;i=i-1{ + bullet[i].print() + } + for i=bullet_my.length()-1;i>=0;i=i-1{ + bullet_my[i].print() + } + if(died.val.not()){player_plane.print()} + for i=aircraft.length()-1;i>=0;i=i-1{ + aircraft[i].print() + } + // for i=laser.length()-1;i>=0;i=i-1{ + // laser[i].print() + // } + for i=cartridge.length()-1;i>=0;i=i-1{ + cartridge[i].print() + } + died.val=died.val||player_plane.die() + //状态栏###################################################################################################### + // column() + @wasm4.text(score.val.to_string(),0,10) + @wasm4.text("Score",0,0) + @wasm4.text("HP: ",0,150) + @wasm4.text((((player_plane.hp*100).to_int().to_double())/100.0).to_string(),20,150) + // @wasm4.text(ttime.val.to_string(),90,150) + // @wasm4.text("Frames",120,150) + @wasm4.text((((ttime.val.to_double()/60.0*100).to_int()).to_double()/100).to_string()+"s",110,150) +} + +//生成################################################################################################################################################ + +// let generate_planelist: FixedArray[Int]=[5,4,12] +fn generate_plane()->Unit{ + let mut type_:Int=0; + if(random.uint(limit=1000)>=20) {return} + if(random.uint(limit=100)<=60) {type_=4} + else { + if(random.uint(limit=100)>=30){ + type_=5 + } + else {type_=12} + } + let x={ + ..@antity.plans(type_), + pos:@antity.Location::new( + x=get_rand(), + y=0,type_.reinterpret_as_uint() + ), + } + while(x.is_out_partly()) { + x.pos.x=get_rand() + } + aircraft.push(x) +} + +fn shoot(plane:@antity.Aircraft)->Unit{ + for i=plane.bullet_exit_point.length()-1;i>=0;i=i-1{ + if(plane.bullet_exit_point[i].last_shoot>=plane.bullet_exit_point[i].shoot_speed) { + if(plane.type_==3) { + bullet_my.push({ + ..@antity.bullet(plane.bullet_exit_point[i].type_), + pos:@antity.Location::new( + x=plane.bullet_exit_point[i].x.to_double()+plane.pos.x, + y=plane.bullet_exit_point[i].y.to_double()+plane.pos.y, + plane.bullet_exit_point[i].type_.reinterpret_as_uint()) + })} + else { + let mut omg:Double=@math.atan((plane.bullet_exit_point[i].y.to_double()+plane.pos.y-player_plane.pos.y)/(plane.bullet_exit_point[i].x.to_double()+plane.pos.x-player_plane.pos.x))*57.30 + if(plane.pos.x>=player_plane.pos.x){ omg=omg+180} + bullet.push({ + ..@antity.bullet(plane.bullet_exit_point[i].type_), + pos:@antity.Location::new( + x=plane.bullet_exit_point[i].x.to_double()+plane.pos.x, + y=plane.bullet_exit_point[i].y.to_double()+plane.pos.y, + plane.bullet_exit_point[i].type_.reinterpret_as_uint()), + dir:omg})} + plane.bullet_exit_point[i].last_shoot=plane.bullet_exit_point[i].last_shoot%plane.bullet_exit_point[i].shoot_speed + update_shoot(plane) + } + else {plane.bullet_exit_point[i].last_shoot=plane.bullet_exit_point[i].last_shoot+1} + } +} + +fn update_shoot(plane:@antity.Aircraft)->Unit{ + if(plane.type_==4) {return} + for i=plane.bullet_exit_point.length()-1;i>=0;i=i-1{ + if(plane.bullet_exit_point[i].limit==0){ + plane.bullet_exit_point.remove(i) |> ignore + continue; + } + if(plane.bullet_exit_point[i].limit==-1) {continue;} + plane.bullet_exit_point[i].limit=plane.bullet_exit_point[i].limit-1; + } + if(plane.bullet_exit_point.length()==0){ + let lin=@antity.default_bullet(plane.type_) + plane.bullet_exit_point.resize(lin.length(),@antity.Bullet_exit_point::new(1,1,1,1,1)) + for i=plane.bullet_exit_point.length()-1;i>=0;i=i-1{ + plane.bullet_exit_point[i]={..@antity.default_bullet(plane.type_)[i]} + } + } +} + +fn generate_cartridge()->Unit{ + if(random.uint(limit =100)<=20){ + let x={ + ..@antity.cartridge(8), + pos:@antity.Location::new( + x=get_rand(), + y=0, + 8 + ) + } + while(x.is_out_partly()) { + x.pos.x=get_rand() + } + cartridge.push(x) + return + } + if(random.uint(limit =100)<=20){ + let x={ + ..@antity.cartridge(6), + pos:@antity.Location::new( + x=get_rand(), + y=0, + 6 + ) + } + while(x.is_out_partly()) { + x.pos.x=get_rand() + } + cartridge.push(x) + return + } + if(random.uint(limit =100)<=20){ + let x={ + ..@antity.cartridge(7), + pos:@antity.Location::new( + x=get_rand(), + y=0, + 7 + ) + } + while(x.is_out_partly()) { + x.pos.x=get_rand() + } + cartridge.push(x) + return + } +} + +//生成################################################################################################################################################ + +//自身飞机操作控制######################################################################################################################################## +fn update_self()->Unit{ + let mut dir:Double=0; + if (button_state.val.button_down&&button_state.val.button_up).not()&&(button_state.val.button_down||button_state.val.button_up){ + if button_state.val.button_down { + if (button_state.val.button_right||button_state.val.button_left).not()||(button_state.val.button_right&&button_state.val.button_left) {dir=90} + else if(button_state.val.button_right){ + dir=45; + } + else if button_state.val.button_left {dir=135.0;} + + } + else{ + if (button_state.val.button_right||button_state.val.button_left).not()||(button_state.val.button_right&&button_state.val.button_left) {dir=270} + else if(button_state.val.button_right){ + dir=360.0-45; + } + else if button_state.val.button_left {dir=225;} + } + + } + else{ + if button_state.val.button_right {dir=0} + else if button_state.val.button_left {dir=180} + } + player_plane.dir=dir + player_plane.update_pos() +} +//自身飞机操作控制######################################################################################################################################## + +//Game Over######################################################################################################################################################################### +fn game_over()->Unit{ + @wasm4.text("Score:"+score.val.to_string(),2,55) + @wasm4.text("Time:"+(((ttime.val.to_double()/60.0*100).to_int()).to_double()/100).to_string()+"s",2,68) + @wasm4.text("Press R to restart.",2,82) + @wasm4.text("U DIED",50,30) + @wasm4.text("If u get a crush",8,120) + @wasm4.text("Kill more enemies.",10,130) +} + +//Game Over######################################################################################################################################################################### \ No newline at end of file diff --git "a/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/interface/interface_control.mbt" "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/interface/interface_control.mbt" new file mode 100644 index 0000000..dc4d782 --- /dev/null +++ "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/interface/interface_control.mbt" @@ -0,0 +1,11 @@ +pub let interface_type:Ref[Int]=Ref::new(1); +let button_state:Ref[@wasm4.GamePad]=Ref::new(@wasm4.GamePad::default()) +// pub let pubsound_effects:@immut/priority_queue.T[@antity.ToneForPub]=@immut/priority_queue.new(); +pub let low_y=150 + +let interface_gaming1:Int=1 + +pub fn interface()->Unit{ + button_state.val=@wasm4.get_gamepad() + if interface_type.val==interface_gaming1 {gaming1()} +} \ No newline at end of file diff --git "a/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/interface/moon.pkg.json" "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/interface/moon.pkg.json" new file mode 100644 index 0000000..d8294bd --- /dev/null +++ "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/interface/moon.pkg.json" @@ -0,0 +1,7 @@ +{ + "import": [ + "moonbitlang/wasm4", + {"path": "GAME/antity","alias": "antity"}, + "GAME/time_cnt" + ] +} \ No newline at end of file diff --git "a/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/moon.pkg.json" "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/moon.pkg.json" new file mode 100644 index 0000000..e43d4ed --- /dev/null +++ "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/moon.pkg.json" @@ -0,0 +1,20 @@ +{ + "import": [ + "moonbitlang/wasm4", + "GAME/interface", + "GAME/time_cnt" + ], + "link": { + "wasm": { + "exports": [ + "start", + "update" + ], + "import-memory": { + "module": "env", + "name": "memory" + }, + "heap-start-address": 6560 + } + } +} \ No newline at end of file diff --git "a/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/time_cnt/moon.pkg.json" "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/time_cnt/moon.pkg.json" new file mode 100644 index 0000000..05b4f54 --- /dev/null +++ "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/time_cnt/moon.pkg.json" @@ -0,0 +1,5 @@ +{ + "import": [ + "moonbitlang/wasm4" + ] + } \ No newline at end of file diff --git "a/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/time_cnt/timer.mbt" "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/time_cnt/timer.mbt" new file mode 100644 index 0000000..0cb670c --- /dev/null +++ "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/time_cnt/timer.mbt" @@ -0,0 +1,9 @@ +let frame_cnt:Ref[UInt]=Ref::new(0) + +pub fn update_time()->Unit{ + frame_cnt.val=frame_cnt.val+1; +} + +pub fn get_time()->UInt{ + frame_cnt.val +} \ No newline at end of file diff --git "a/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/top.mbt" "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/top.mbt" new file mode 100644 index 0000000..ce0460b --- /dev/null +++ "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/src/top.mbt" @@ -0,0 +1,15 @@ +pub fn start() -> Unit { + @wasm4.set_palette(1,@wasm4.rgb(1377129)) + @wasm4.set_palette(4,@wasm4.rgb(11221214)) + @wasm4.set_palette(3,@wasm4.rgb(16754473)) + @wasm4.set_palette(2,@wasm4.rgb(5224703)) + //初始化调色板,之后调色板禁止更改!! +} + +pub fn update() -> Unit { + // @wasm4.trace("312312") + @time_cnt.update_time(); + // @antity.player_Plane_1_frame.print() + @interface.interface() + // @antity.player_Plane.print() +} From 8df47befa8530d5d39565e91ce74789388ffe606 Mon Sep 17 00:00:00 2001 From: Demonmasterlqx <183842220@qq.com> Date: Thu, 14 Nov 2024 19:43:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=95=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../README.md" | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git "a/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/README.md" "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/README.md" index 70997b2..2766b0f 100644 --- "a/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/README.md" +++ "b/teams/\345\244\251\345\234\260\344\270\200\357\274\201\345\261\213\357\274\201\345\244\247\347\210\261\347\233\237/README.md" @@ -29,4 +29,10 @@ 拾取后发射一段时间的高伤害高爆弹 -## 游戏有很多其他的“特性”建议自行游玩查看QWQ \ No newline at end of file +## 游戏有很多其他的“特性”建议自行游玩查看QWQ + +## 宣传链接 + +[Moonbit初体验——大一小白游戏创作 - Daster的文章 - 知乎](https://zhuanlan.zhihu.com/p/6863463180) + +[天地一!屋!大爱盟——飞机大战 at moonbit 开发心得 - 轩Demonmaster - 博客园](https://www.cnblogs.com/LQX-OI/p/18540898) \ No newline at end of file