diff --git a/assets/coinBronze.png b/assets/coinBronze.png new file mode 100644 index 0000000..cf346cb Binary files /dev/null and b/assets/coinBronze.png differ diff --git a/assets/coinGold.png b/assets/coinGold.png new file mode 100644 index 0000000..4df83e2 Binary files /dev/null and b/assets/coinGold.png differ diff --git a/assets/coinSilver.png b/assets/coinSilver.png new file mode 100644 index 0000000..dc36564 Binary files /dev/null and b/assets/coinSilver.png differ diff --git a/assets/gold_1.png b/assets/gold_1.png new file mode 100644 index 0000000..e9f4428 Binary files /dev/null and b/assets/gold_1.png differ diff --git a/assets/gold_2.png b/assets/gold_2.png new file mode 100644 index 0000000..e725c14 Binary files /dev/null and b/assets/gold_2.png differ diff --git a/assets/gold_3.png b/assets/gold_3.png new file mode 100644 index 0000000..45dd956 Binary files /dev/null and b/assets/gold_3.png differ diff --git a/assets/laserBlue01.png b/assets/laserBlue01.png new file mode 100644 index 0000000..9aa12b4 Binary files /dev/null and b/assets/laserBlue01.png differ diff --git a/assets/laserRed01.png b/assets/laserRed01.png new file mode 100644 index 0000000..5e467b6 Binary files /dev/null and b/assets/laserRed01.png differ diff --git a/assets/star.png b/assets/star.png new file mode 100644 index 0000000..20f5dd1 Binary files /dev/null and b/assets/star.png differ diff --git a/assets/tankBlue_barrel1.png b/assets/tankBlue_barrel1.png new file mode 100644 index 0000000..39d8819 Binary files /dev/null and b/assets/tankBlue_barrel1.png differ diff --git a/assets/tankBlue_barrel1_outline.png b/assets/tankBlue_barrel1_outline.png new file mode 100644 index 0000000..bec4e4b Binary files /dev/null and b/assets/tankBlue_barrel1_outline.png differ diff --git a/assets/tankBlue_barrel2.png b/assets/tankBlue_barrel2.png new file mode 100644 index 0000000..6fd2e8d Binary files /dev/null and b/assets/tankBlue_barrel2.png differ diff --git a/assets/tankBlue_barrel2_outline.png b/assets/tankBlue_barrel2_outline.png new file mode 100644 index 0000000..ee170db Binary files /dev/null and b/assets/tankBlue_barrel2_outline.png differ diff --git a/assets/tankBlue_barrel3.png b/assets/tankBlue_barrel3.png new file mode 100644 index 0000000..7957323 Binary files /dev/null and b/assets/tankBlue_barrel3.png differ diff --git a/assets/tankBlue_barrel3_outline.png b/assets/tankBlue_barrel3_outline.png new file mode 100644 index 0000000..9d813fa Binary files /dev/null and b/assets/tankBlue_barrel3_outline.png differ diff --git a/assets/tankBody_bigRed.png b/assets/tankBody_bigRed.png new file mode 100644 index 0000000..fd774be Binary files /dev/null and b/assets/tankBody_bigRed.png differ diff --git a/assets/tankBody_bigRed_outline.png b/assets/tankBody_bigRed_outline.png new file mode 100644 index 0000000..b11914a Binary files /dev/null and b/assets/tankBody_bigRed_outline.png differ diff --git a/assets/tankBody_blue.png b/assets/tankBody_blue.png new file mode 100644 index 0000000..9c56dd5 Binary files /dev/null and b/assets/tankBody_blue.png differ diff --git a/assets/tankBody_blue_outline.png b/assets/tankBody_blue_outline.png new file mode 100644 index 0000000..55294da Binary files /dev/null and b/assets/tankBody_blue_outline.png differ diff --git a/assets/tankBody_dark.png b/assets/tankBody_dark.png new file mode 100644 index 0000000..5f35c35 Binary files /dev/null and b/assets/tankBody_dark.png differ diff --git a/assets/tankBody_darkLarge.png b/assets/tankBody_darkLarge.png new file mode 100644 index 0000000..14e232a Binary files /dev/null and b/assets/tankBody_darkLarge.png differ diff --git a/assets/tankBody_darkLarge_outline.png b/assets/tankBody_darkLarge_outline.png new file mode 100644 index 0000000..7666110 Binary files /dev/null and b/assets/tankBody_darkLarge_outline.png differ diff --git a/assets/tankBody_dark_outline.png b/assets/tankBody_dark_outline.png new file mode 100644 index 0000000..62f58fa Binary files /dev/null and b/assets/tankBody_dark_outline.png differ diff --git a/assets/tankBody_green.png b/assets/tankBody_green.png new file mode 100644 index 0000000..473a19e Binary files /dev/null and b/assets/tankBody_green.png differ diff --git a/assets/tankBody_green_outline.png b/assets/tankBody_green_outline.png new file mode 100644 index 0000000..17f44bb Binary files /dev/null and b/assets/tankBody_green_outline.png differ diff --git a/assets/tankBody_huge.png b/assets/tankBody_huge.png new file mode 100644 index 0000000..9da775e Binary files /dev/null and b/assets/tankBody_huge.png differ diff --git a/assets/tankBody_huge_outline.png b/assets/tankBody_huge_outline.png new file mode 100644 index 0000000..a18e8ca Binary files /dev/null and b/assets/tankBody_huge_outline.png differ diff --git a/assets/tankBody_red.png b/assets/tankBody_red.png new file mode 100644 index 0000000..aa49727 Binary files /dev/null and b/assets/tankBody_red.png differ diff --git a/assets/tankBody_red_outline.png b/assets/tankBody_red_outline.png new file mode 100644 index 0000000..9866931 Binary files /dev/null and b/assets/tankBody_red_outline.png differ diff --git a/assets/tankBody_sand.png b/assets/tankBody_sand.png new file mode 100644 index 0000000..f2feb37 Binary files /dev/null and b/assets/tankBody_sand.png differ diff --git a/assets/tankBody_sand_outline.png b/assets/tankBody_sand_outline.png new file mode 100644 index 0000000..fe4d5dc Binary files /dev/null and b/assets/tankBody_sand_outline.png differ diff --git a/assets/tankDark_barrel1.png b/assets/tankDark_barrel1.png new file mode 100644 index 0000000..7f5b62b Binary files /dev/null and b/assets/tankDark_barrel1.png differ diff --git a/assets/tankDark_barrel1_outline.png b/assets/tankDark_barrel1_outline.png new file mode 100644 index 0000000..4b4b76f Binary files /dev/null and b/assets/tankDark_barrel1_outline.png differ diff --git a/assets/tankDark_barrel2.png b/assets/tankDark_barrel2.png new file mode 100644 index 0000000..e2f5222 Binary files /dev/null and b/assets/tankDark_barrel2.png differ diff --git a/assets/tankDark_barrel2_outline.png b/assets/tankDark_barrel2_outline.png new file mode 100644 index 0000000..5acc557 Binary files /dev/null and b/assets/tankDark_barrel2_outline.png differ diff --git a/assets/tankDark_barrel3.png b/assets/tankDark_barrel3.png new file mode 100644 index 0000000..dbed97c Binary files /dev/null and b/assets/tankDark_barrel3.png differ diff --git a/assets/tankDark_barrel3_outline.png b/assets/tankDark_barrel3_outline.png new file mode 100644 index 0000000..edd17dd Binary files /dev/null and b/assets/tankDark_barrel3_outline.png differ diff --git a/assets/tankGreen_barrel1.png b/assets/tankGreen_barrel1.png new file mode 100644 index 0000000..d239762 Binary files /dev/null and b/assets/tankGreen_barrel1.png differ diff --git a/assets/tankGreen_barrel1_outline.png b/assets/tankGreen_barrel1_outline.png new file mode 100644 index 0000000..55f6ecc Binary files /dev/null and b/assets/tankGreen_barrel1_outline.png differ diff --git a/assets/tankGreen_barrel2.png b/assets/tankGreen_barrel2.png new file mode 100644 index 0000000..ed9119c Binary files /dev/null and b/assets/tankGreen_barrel2.png differ diff --git a/assets/tankGreen_barrel2_outline.png b/assets/tankGreen_barrel2_outline.png new file mode 100644 index 0000000..51f3285 Binary files /dev/null and b/assets/tankGreen_barrel2_outline.png differ diff --git a/assets/tankGreen_barrel3.png b/assets/tankGreen_barrel3.png new file mode 100644 index 0000000..2dd1b17 Binary files /dev/null and b/assets/tankGreen_barrel3.png differ diff --git a/assets/tankGreen_barrel3_outline.png b/assets/tankGreen_barrel3_outline.png new file mode 100644 index 0000000..df0d795 Binary files /dev/null and b/assets/tankGreen_barrel3_outline.png differ diff --git a/assets/tankRed_barrel1.png b/assets/tankRed_barrel1.png new file mode 100644 index 0000000..2935252 Binary files /dev/null and b/assets/tankRed_barrel1.png differ diff --git a/assets/tankRed_barrel1_outline.png b/assets/tankRed_barrel1_outline.png new file mode 100644 index 0000000..5182b4f Binary files /dev/null and b/assets/tankRed_barrel1_outline.png differ diff --git a/assets/tankRed_barrel2.png b/assets/tankRed_barrel2.png new file mode 100644 index 0000000..7535233 Binary files /dev/null and b/assets/tankRed_barrel2.png differ diff --git a/assets/tankRed_barrel2_outline.png b/assets/tankRed_barrel2_outline.png new file mode 100644 index 0000000..6f76326 Binary files /dev/null and b/assets/tankRed_barrel2_outline.png differ diff --git a/assets/tankRed_barrel3.png b/assets/tankRed_barrel3.png new file mode 100644 index 0000000..2b2bc84 Binary files /dev/null and b/assets/tankRed_barrel3.png differ diff --git a/assets/tankRed_barrel3_outline.png b/assets/tankRed_barrel3_outline.png new file mode 100644 index 0000000..6a04984 Binary files /dev/null and b/assets/tankRed_barrel3_outline.png differ diff --git a/assets/tankSand_barrel1.png b/assets/tankSand_barrel1.png new file mode 100644 index 0000000..91cb835 Binary files /dev/null and b/assets/tankSand_barrel1.png differ diff --git a/assets/tankSand_barrel1_outline.png b/assets/tankSand_barrel1_outline.png new file mode 100644 index 0000000..811b308 Binary files /dev/null and b/assets/tankSand_barrel1_outline.png differ diff --git a/assets/tankSand_barrel2.png b/assets/tankSand_barrel2.png new file mode 100644 index 0000000..8a2e622 Binary files /dev/null and b/assets/tankSand_barrel2.png differ diff --git a/assets/tankSand_barrel2_outline.png b/assets/tankSand_barrel2_outline.png new file mode 100644 index 0000000..a56ca9e Binary files /dev/null and b/assets/tankSand_barrel2_outline.png differ diff --git a/assets/tankSand_barrel3.png b/assets/tankSand_barrel3.png new file mode 100644 index 0000000..06d56ec Binary files /dev/null and b/assets/tankSand_barrel3.png differ diff --git a/assets/tankSand_barrel3_outline.png b/assets/tankSand_barrel3_outline.png new file mode 100644 index 0000000..ccb47bb Binary files /dev/null and b/assets/tankSand_barrel3_outline.png differ diff --git a/assets/tank_blue.png b/assets/tank_blue.png new file mode 100644 index 0000000..685aa8b Binary files /dev/null and b/assets/tank_blue.png differ diff --git a/assets/tank_dark.png b/assets/tank_dark.png new file mode 100644 index 0000000..202b092 Binary files /dev/null and b/assets/tank_dark.png differ diff --git a/assets/tank_green.png b/assets/tank_green.png new file mode 100644 index 0000000..7be97cb Binary files /dev/null and b/assets/tank_green.png differ diff --git a/assets/tank_red.png b/assets/tank_red.png new file mode 100644 index 0000000..431cb88 Binary files /dev/null and b/assets/tank_red.png differ diff --git a/assets/tank_sand.png b/assets/tank_sand.png new file mode 100644 index 0000000..5d37aea Binary files /dev/null and b/assets/tank_sand.png differ diff --git a/assets/tileGrass1.png b/assets/tileGrass1.png new file mode 100644 index 0000000..57e4b71 Binary files /dev/null and b/assets/tileGrass1.png differ diff --git a/assets/tileGrass2.png b/assets/tileGrass2.png new file mode 100644 index 0000000..bb64831 Binary files /dev/null and b/assets/tileGrass2.png differ diff --git a/assets/tileGrass_roadCornerLL.png b/assets/tileGrass_roadCornerLL.png new file mode 100644 index 0000000..29548a5 Binary files /dev/null and b/assets/tileGrass_roadCornerLL.png differ diff --git a/assets/tileGrass_roadCornerLR.png b/assets/tileGrass_roadCornerLR.png new file mode 100644 index 0000000..e8a1af6 Binary files /dev/null and b/assets/tileGrass_roadCornerLR.png differ diff --git a/assets/tileGrass_roadCornerUL.png b/assets/tileGrass_roadCornerUL.png new file mode 100644 index 0000000..ceaea03 Binary files /dev/null and b/assets/tileGrass_roadCornerUL.png differ diff --git a/assets/tileGrass_roadCornerUR.png b/assets/tileGrass_roadCornerUR.png new file mode 100644 index 0000000..8aafa7d Binary files /dev/null and b/assets/tileGrass_roadCornerUR.png differ diff --git a/assets/tileGrass_roadCrossing.png b/assets/tileGrass_roadCrossing.png new file mode 100644 index 0000000..5f83769 Binary files /dev/null and b/assets/tileGrass_roadCrossing.png differ diff --git a/assets/tileGrass_roadCrossingRound.png b/assets/tileGrass_roadCrossingRound.png new file mode 100644 index 0000000..298e1b0 Binary files /dev/null and b/assets/tileGrass_roadCrossingRound.png differ diff --git a/assets/tileGrass_roadEast.png b/assets/tileGrass_roadEast.png new file mode 100644 index 0000000..076d8b7 Binary files /dev/null and b/assets/tileGrass_roadEast.png differ diff --git a/assets/tileGrass_roadNorth.png b/assets/tileGrass_roadNorth.png new file mode 100644 index 0000000..749bf43 Binary files /dev/null and b/assets/tileGrass_roadNorth.png differ diff --git a/assets/tileGrass_roadSplitE.png b/assets/tileGrass_roadSplitE.png new file mode 100644 index 0000000..b193506 Binary files /dev/null and b/assets/tileGrass_roadSplitE.png differ diff --git a/assets/tileGrass_roadSplitN.png b/assets/tileGrass_roadSplitN.png new file mode 100644 index 0000000..46a6004 Binary files /dev/null and b/assets/tileGrass_roadSplitN.png differ diff --git a/assets/tileGrass_roadSplitS.png b/assets/tileGrass_roadSplitS.png new file mode 100644 index 0000000..fc6646c Binary files /dev/null and b/assets/tileGrass_roadSplitS.png differ diff --git a/assets/tileGrass_roadSplitW.png b/assets/tileGrass_roadSplitW.png new file mode 100644 index 0000000..ecb7ca0 Binary files /dev/null and b/assets/tileGrass_roadSplitW.png differ diff --git a/assets/tileGrass_roadTransitionE.png b/assets/tileGrass_roadTransitionE.png new file mode 100644 index 0000000..ad77aca Binary files /dev/null and b/assets/tileGrass_roadTransitionE.png differ diff --git a/assets/tileGrass_roadTransitionE_dirt.png b/assets/tileGrass_roadTransitionE_dirt.png new file mode 100644 index 0000000..5040d36 Binary files /dev/null and b/assets/tileGrass_roadTransitionE_dirt.png differ diff --git a/assets/tileGrass_roadTransitionN.png b/assets/tileGrass_roadTransitionN.png new file mode 100644 index 0000000..10da81d Binary files /dev/null and b/assets/tileGrass_roadTransitionN.png differ diff --git a/assets/tileGrass_roadTransitionN_dirt.png b/assets/tileGrass_roadTransitionN_dirt.png new file mode 100644 index 0000000..a68d7ea Binary files /dev/null and b/assets/tileGrass_roadTransitionN_dirt.png differ diff --git a/assets/tileGrass_roadTransitionS.png b/assets/tileGrass_roadTransitionS.png new file mode 100644 index 0000000..699892b Binary files /dev/null and b/assets/tileGrass_roadTransitionS.png differ diff --git a/assets/tileGrass_roadTransitionS_dirt.png b/assets/tileGrass_roadTransitionS_dirt.png new file mode 100644 index 0000000..7ed7f2d Binary files /dev/null and b/assets/tileGrass_roadTransitionS_dirt.png differ diff --git a/assets/tileGrass_roadTransitionW.png b/assets/tileGrass_roadTransitionW.png new file mode 100644 index 0000000..e243b9b Binary files /dev/null and b/assets/tileGrass_roadTransitionW.png differ diff --git a/assets/tileGrass_roadTransitionW_dirt.png b/assets/tileGrass_roadTransitionW_dirt.png new file mode 100644 index 0000000..01cf395 Binary files /dev/null and b/assets/tileGrass_roadTransitionW_dirt.png differ diff --git a/assets/tileGrass_transitionE.png b/assets/tileGrass_transitionE.png new file mode 100644 index 0000000..7bd0c79 Binary files /dev/null and b/assets/tileGrass_transitionE.png differ diff --git a/assets/tileGrass_transitionN.png b/assets/tileGrass_transitionN.png new file mode 100644 index 0000000..f4e7b7f Binary files /dev/null and b/assets/tileGrass_transitionN.png differ diff --git a/assets/tileGrass_transitionS.png b/assets/tileGrass_transitionS.png new file mode 100644 index 0000000..ea5b276 Binary files /dev/null and b/assets/tileGrass_transitionS.png differ diff --git a/assets/tileGrass_transitionW.png b/assets/tileGrass_transitionW.png new file mode 100644 index 0000000..1143068 Binary files /dev/null and b/assets/tileGrass_transitionW.png differ diff --git a/assets/tileSand1.png b/assets/tileSand1.png new file mode 100644 index 0000000..c88544e Binary files /dev/null and b/assets/tileSand1.png differ diff --git a/assets/tileSand2.png b/assets/tileSand2.png new file mode 100644 index 0000000..a2fe6d5 Binary files /dev/null and b/assets/tileSand2.png differ diff --git a/assets/tileSand_roadCornerLL.png b/assets/tileSand_roadCornerLL.png new file mode 100644 index 0000000..41181ba Binary files /dev/null and b/assets/tileSand_roadCornerLL.png differ diff --git a/assets/tileSand_roadCornerLR.png b/assets/tileSand_roadCornerLR.png new file mode 100644 index 0000000..1370117 Binary files /dev/null and b/assets/tileSand_roadCornerLR.png differ diff --git a/assets/tileSand_roadCornerUL.png b/assets/tileSand_roadCornerUL.png new file mode 100644 index 0000000..500f8e6 Binary files /dev/null and b/assets/tileSand_roadCornerUL.png differ diff --git a/assets/tileSand_roadCornerUR.png b/assets/tileSand_roadCornerUR.png new file mode 100644 index 0000000..d4b1bb7 Binary files /dev/null and b/assets/tileSand_roadCornerUR.png differ diff --git a/assets/tileSand_roadCrossing.png b/assets/tileSand_roadCrossing.png new file mode 100644 index 0000000..487506c Binary files /dev/null and b/assets/tileSand_roadCrossing.png differ diff --git a/assets/tileSand_roadCrossingRound.png b/assets/tileSand_roadCrossingRound.png new file mode 100644 index 0000000..d35a868 Binary files /dev/null and b/assets/tileSand_roadCrossingRound.png differ diff --git a/assets/tileSand_roadEast.png b/assets/tileSand_roadEast.png new file mode 100644 index 0000000..5a7cb32 Binary files /dev/null and b/assets/tileSand_roadEast.png differ diff --git a/assets/tileSand_roadNorth.png b/assets/tileSand_roadNorth.png new file mode 100644 index 0000000..f8b08da Binary files /dev/null and b/assets/tileSand_roadNorth.png differ diff --git a/assets/tileSand_roadSplitE.png b/assets/tileSand_roadSplitE.png new file mode 100644 index 0000000..c9d44a4 Binary files /dev/null and b/assets/tileSand_roadSplitE.png differ diff --git a/assets/tileSand_roadSplitN.png b/assets/tileSand_roadSplitN.png new file mode 100644 index 0000000..258d3c4 Binary files /dev/null and b/assets/tileSand_roadSplitN.png differ diff --git a/assets/tileSand_roadSplitS.png b/assets/tileSand_roadSplitS.png new file mode 100644 index 0000000..d3e9038 Binary files /dev/null and b/assets/tileSand_roadSplitS.png differ diff --git a/assets/tileSand_roadSplitW.png b/assets/tileSand_roadSplitW.png new file mode 100644 index 0000000..6324b01 Binary files /dev/null and b/assets/tileSand_roadSplitW.png differ diff --git a/assets/tracksDouble.png b/assets/tracksDouble.png new file mode 100644 index 0000000..437a366 Binary files /dev/null and b/assets/tracksDouble.png differ diff --git a/assets/tracksLarge.png b/assets/tracksLarge.png new file mode 100644 index 0000000..c14c6bf Binary files /dev/null and b/assets/tracksLarge.png differ diff --git a/assets/tracksSmall.png b/assets/tracksSmall.png new file mode 100644 index 0000000..fd4b68b Binary files /dev/null and b/assets/tracksSmall.png differ diff --git a/assets/treeBrown_large.png b/assets/treeBrown_large.png new file mode 100644 index 0000000..ce03d16 Binary files /dev/null and b/assets/treeBrown_large.png differ diff --git a/assets/treeBrown_small.png b/assets/treeBrown_small.png new file mode 100644 index 0000000..bca54d7 Binary files /dev/null and b/assets/treeBrown_small.png differ diff --git a/assets/treeGreen_large.png b/assets/treeGreen_large.png new file mode 100644 index 0000000..ef8aa7f Binary files /dev/null and b/assets/treeGreen_large.png differ diff --git a/assets/treeGreen_small.png b/assets/treeGreen_small.png new file mode 100644 index 0000000..7ff8613 Binary files /dev/null and b/assets/treeGreen_small.png differ diff --git a/bonus.py b/bonus.py new file mode 100644 index 0000000..40ab2b5 --- /dev/null +++ b/bonus.py @@ -0,0 +1,24 @@ +import arcade + +class Bonus(arcade.Sprite): + ls = arcade.SpriteList() + def __init__(self,x,y,type='star'): + super().__init__( + './assets/star.png', + scale=0.5) + self.type = type + self.center_x = x + self.center_y = y + Bonus.ls.append(self) + def destroy(self): + Bonus.ls.remove(self) + @classmethod + def get_colls(cls,sprite): + return arcade.check_for_collision_with_list(sprite, cls.ls) + @classmethod + def update_list(cls,time_delta): + Bonus.ls.update() + + @classmethod + def draw(cls): + cls.ls.draw() diff --git a/bullet.py b/bullet.py new file mode 100644 index 0000000..5556348 --- /dev/null +++ b/bullet.py @@ -0,0 +1,26 @@ +import arcade +import math + +class Bullet(arcade.Sprite): + ls = arcade.SpriteList() + def __init__(self,x,y,a,shift=0): + super().__init__( + './assets/laserBlue01.png', + scale=0.7) + self.angle = a + self.center_x = x + math.sin(self.angle * math.pi / 180) * shift + self.center_y = y + math.cos(self.angle * math.pi / 180) * shift + self.speed = 10 + Bullet.ls.append(self) + + @classmethod + def update_list(cls): + for bullet in cls.ls: + bullet.change_x = math.sin(bullet.angle * math.pi / 180) * bullet.speed + bullet.change_y = math.cos(bullet.angle * math.pi / 180) * bullet.speed + bullet.update() + + @classmethod + def draw(cls): + cls.ls.draw() + diff --git a/main.py b/main.py new file mode 100644 index 0000000..fe16715 --- /dev/null +++ b/main.py @@ -0,0 +1,57 @@ +import arcade +import math +from tank import Tank +from map import Map +from bullet import Bullet +from bonus import Bonus + +SCREEN_WIDTH = 768 +SCREEN_HEIGHT = 576 + +class MainView(arcade.View): + def __init__(self): + super().__init__() + self.background_color = (100,100,200) + self.map = Map(SCREEN_WIDTH,SCREEN_HEIGHT,64,64) + self.player = list(filter(lambda tank: tank.type=='player', Tank.ls))[0] + + def on_draw(self): + self.clear() + self.map.draw() + Tank.draw() + Bonus.draw() + Bullet.draw() + + def on_update(self,time_delta): + Tank.update() + Bonus.update_list(time_delta) + Bullet.update_list() + + def on_mouse_motion(self,x,y,dx,dy): + self.player.gun_to_xy(x,y) + + def on_key_press(self,key,mod): + if key == arcade.key.A: + self.last_key = key + self.player.move(-1,0) + elif key == arcade.key.D: + self.last_key = key + self.player.move(1,0) + elif key == arcade.key.W: + self.last_key = key + self.player.move(0,1) + elif key == arcade.key.S: + self.last_key = key + self.player.move(0,-1) + def on_key_release(self,key,mod): + if self.last_key == key: + self.player.move(0,0) + def on_mouse_press(self,x,y,but,mod): + if but == 1: + self.player.shoot() + +if __name__ == '__main__': + window = arcade.Window(SCREEN_WIDTH,SCREEN_HEIGHT,"Моя игра") + view = MainView() + window.show_view(view) + arcade.run() diff --git a/map.py b/map.py new file mode 100644 index 0000000..dca897a --- /dev/null +++ b/map.py @@ -0,0 +1,86 @@ +import arcade +from tank import Tank +from bonus import Bonus +from random import randint + +class Map(): + ground_tiles = arcade.SpriteList() + object_tiles = arcade.SpriteList() + def __init__(self,width,height,tw,th): + self.height = height + self.width = width + self.tilew = tw + self.tileh = th + self.ground = [ + ' ........ ', + ' . ', + ' . ', + ' . ', + ' . ', + ' . ', + ' . ', + ' . ', + ' ', + ] + self.objects = [ + ' ', + ' e e ', + ' s ', + ' ', + ' p ', + ' ', + ' e ', + ' ', + ' s e ', + ] + self.setup() + def init_ground(self): + for i in range(len(self.ground)): + for j in range(len(self.ground[i])): + if self.ground[i][j] == ' ': + tile = arcade.Sprite( + './assets/tileGrass1.png', + scale=1 + ) + elif self.ground[i][j] == '.': + tile = arcade.Sprite( + './assets/tileSand1.png', + scale=1 + ) + tile.center_x = self.tilew//2 + j * self.tilew + tile.center_y = self.height - (self.tileh//2 + i * self.tileh) + Map.ground_tiles.append(tile) + def init_objects(self): + for i in range(len(self.objects)): + for j in range(len(self.objects[i])): + if self.objects[i][j] == 'p': + Tank( + self.tilew//2 + j * self.tilew, + self.height - (self.tileh//2 + i * self.tileh), + 'player') + elif self.objects[i][j] == 'e': + Tank( + self.tilew//2 + j * self.tilew, + self.height - (self.tileh//2 + i * self.tileh) + ) + elif self.objects[i][j] == 's': + Bonus( + self.tilew//2 + j * self.tilew, + self.height - (self.tileh//2 + i * self.tileh) + ) + #tile.center_x = self.tilew//2 + j * self.tilew + #tile.center_y = self.height - (self.tileh//2 + i * self.tileh) + #Map.object_tiles.append(tile) + def setup(self): + self.init_ground() + self.init_objects() + def update(self): + if self.coin_timer >= 1: + for i in range(len(self.objects)): + for j in range(len(self.objects[i])): + if self.objects[i][j] == ' ' and randint(0,1) == 1: + self.objects[i][j] = 's' + + def draw(self): + Map.ground_tiles.draw() + #Map.object_tiles.draw() diff --git a/tank.py b/tank.py new file mode 100644 index 0000000..c165569 --- /dev/null +++ b/tank.py @@ -0,0 +1,85 @@ +import arcade +import math +from bullet import Bullet +from bonus import Bonus + +class Tank(): + ls = list() + def __init__(self,x,y,type='enemy'): + self.sp_body = arcade.SpriteList() + self.sp_gun = arcade.SpriteList() + self.type = type + self.gun_angle = 0 + self.speed = 5 + if type == 'player': + body = arcade.Sprite( + './assets/tankBody_blue.png', + scale=1 + ) + gun = arcade.Sprite() + gun.append_texture(arcade.load_texture('./assets/tankBlue_barrel2.png')) + gun.append_texture(arcade.load_texture('./assets/tankBlue_barrel3.png')) + gun.append_texture(arcade.load_texture('./assets/tankBlue_barrel1.png')) + gun.cur = 0 + gun.set_texture(gun.cur) + else: + body = arcade.Sprite( + './assets/tankBody_dark.png', + scale=1 + ) + gun = arcade.Sprite( + './assets/tankBlue_barrel2.png', + scale=1 + ) + body.center_x = x + body.center_y = y + self.sp_body.append(body) + gun.center_x = x + gun.center_y = y + self.sp_gun.append(gun) + + Tank.ls.append(self) + def gun_to_xy(self,x,y): + for gun in self.sp_gun: + gun.angle = math.atan2(x-gun.center_x,y-gun.center_y) * 180 / math.pi + def move(self,dx,dy): + for body in self.sp_body: + body.change_x = dx*self.speed + body.change_y = dy*self.speed + if dx != 0 or dy != 0: + body.angle = math.atan2(dx,dy) * 180 / math.pi + for gun in self.sp_gun: + gun.change_x = dx*self.speed + gun.change_y = dy*self.speed + def shoot(self): + for gun in self.sp_gun: + Bullet( + gun.center_x, + gun.center_y, + gun.angle, + shift = 25 + ) + @classmethod + def update(cls): + for tank in cls.ls: + tank.sp_body.update() + tank.sp_gun.update() + colls = Bonus.get_colls(tank.sp_body[0]) + for bonus in colls: + if bonus.type == 'star': + for gun in tank.sp_gun: + print(gun.cur) + if gun.cur > len(gun.textures): + gun.cur = 0 + gun.set_texture(gun.cur) + else: + gun.cur += 1 + gun.set_texture(gun.cur) + bonus.destroy() + + @classmethod + def draw(cls): + for tank in cls.ls: + tank.sp_body.draw() + tank.sp_gun.draw() + diff --git a/view.py b/view.py new file mode 100644 index 0000000..e69de29