Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 85efacdddb | |||
| dc9a8d52ff | |||
| 1127cd9cb1 | |||
| cf28a4944f |
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"automappingRulesFile": "",
|
|
||||||
"commands": [
|
|
||||||
],
|
|
||||||
"compatibilityVersion": 1100,
|
|
||||||
"extensionsPath": "extensions",
|
|
||||||
"folders": [
|
|
||||||
"."
|
|
||||||
],
|
|
||||||
"properties": [
|
|
||||||
],
|
|
||||||
"propertyTypes": [
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
{
|
|
||||||
"activeFile": "tiles.tsx",
|
|
||||||
"expandedProjectPaths": [
|
|
||||||
".",
|
|
||||||
"levels"
|
|
||||||
],
|
|
||||||
"fileStates": {
|
|
||||||
"levels/default.tmx": {
|
|
||||||
"scale": 0.6685185185185185,
|
|
||||||
"selectedLayer": 0,
|
|
||||||
"viewCenter": {
|
|
||||||
"x": 554.2105263157895,
|
|
||||||
"y": 487.6454293628809
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tiles.tsx": {
|
|
||||||
"dynamicWrapping": false,
|
|
||||||
"scaleInDock": 1,
|
|
||||||
"scaleInEditor": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"last.imagePath": "C:/Users/laktionov/Downloads/git/arcade/assets/pastel_resources_hex",
|
|
||||||
"map.lastUsedFormat": "tmx",
|
|
||||||
"map.layerDataFormat": "1",
|
|
||||||
"map.orientation": "4",
|
|
||||||
"map.renderOrder": "2",
|
|
||||||
"map.tileHeight": 64,
|
|
||||||
"map.tileWidth": 55,
|
|
||||||
"map.width": 20,
|
|
||||||
"openFiles": [
|
|
||||||
"levels/default.tmx",
|
|
||||||
"tiles.tsx"
|
|
||||||
],
|
|
||||||
"project": "Game.tiled-project",
|
|
||||||
"recentFiles": [
|
|
||||||
"levels/default.tmx",
|
|
||||||
"tiles.tsx"
|
|
||||||
],
|
|
||||||
"tileset.lastUsedFormat": "tsx",
|
|
||||||
"tileset.type": 1
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 2.3 KiB |
@@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<map version="1.10" tiledversion="1.12.1" orientation="hexagonal" renderorder="left-down" width="2" height="3" tilewidth="55" tileheight="64" infinite="0" hexsidelength="32" staggeraxis="y" staggerindex="odd" nextlayerid="2" nextobjectid="1">
|
|
||||||
<tileset firstgid="1" source="../tiles.tsx"/>
|
|
||||||
<layer id="1" name="Ground" width="2" height="3">
|
|
||||||
<data encoding="csv">
|
|
||||||
0,40,
|
|
||||||
55,55,
|
|
||||||
0,40
|
|
||||||
</data>
|
|
||||||
</layer>
|
|
||||||
</map>
|
|
||||||
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 1.2 MiB |
@@ -1,61 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<tileset version="1.10" tiledversion="1.12.1" name="Tiles" tilewidth="55" tileheight="64" tilecount="19" columns="0">
|
|
||||||
<grid orientation="orthogonal" width="1" height="1"/>
|
|
||||||
<tile id="38">
|
|
||||||
<image source="pastel_resources_hex/clayHex.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="39">
|
|
||||||
<image source="pastel_resources_hex/desertHex.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="40">
|
|
||||||
<image source="pastel_resources_hex/miscPort0.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="41">
|
|
||||||
<image source="pastel_resources_hex/miscPort1.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="42">
|
|
||||||
<image source="pastel_resources_hex/miscPort2.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="43">
|
|
||||||
<image source="pastel_resources_hex/miscPort3.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="44">
|
|
||||||
<image source="pastel_resources_hex/miscPort4.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="45">
|
|
||||||
<image source="pastel_resources_hex/miscPort5.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="46">
|
|
||||||
<image source="pastel_resources_hex/oreHex.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="47">
|
|
||||||
<image source="pastel_resources_hex/port0.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="48">
|
|
||||||
<image source="pastel_resources_hex/port1.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="49">
|
|
||||||
<image source="pastel_resources_hex/port2.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="50">
|
|
||||||
<image source="pastel_resources_hex/port3.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="51">
|
|
||||||
<image source="pastel_resources_hex/port4.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="52">
|
|
||||||
<image source="pastel_resources_hex/port5.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="53">
|
|
||||||
<image source="pastel_resources_hex/sheepHex.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="54">
|
|
||||||
<image source="pastel_resources_hex/waterHex.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="55">
|
|
||||||
<image source="pastel_resources_hex/wheatHex.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
<tile id="56">
|
|
||||||
<image source="pastel_resources_hex/woodHex.gif" width="55" height="64"/>
|
|
||||||
</tile>
|
|
||||||
</tileset>
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"title":"Велопрокат",
|
|
||||||
"rent":20,
|
|
||||||
"h1":10,
|
|
||||||
"h2":30,
|
|
||||||
"h3":90,
|
|
||||||
"h4":10,
|
|
||||||
"mortage":30,
|
|
||||||
"iins":50,
|
|
||||||
"group":1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title":"Пони-клуб",
|
|
||||||
"rent":20,
|
|
||||||
"h1":10,
|
|
||||||
"h2":30,
|
|
||||||
"h3":90,
|
|
||||||
"h4":10,
|
|
||||||
"mortage":30,
|
|
||||||
"iins":50,
|
|
||||||
"group":1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title":"Пони-клуб",
|
|
||||||
"rent":20,
|
|
||||||
"h1":10,
|
|
||||||
"h2":30,
|
|
||||||
"h3":90,
|
|
||||||
"h4":10,
|
|
||||||
"mortage":30,
|
|
||||||
"iins":50,
|
|
||||||
"group":1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title":"Пони-клуб",
|
|
||||||
"rent":20,
|
|
||||||
"h1":10,
|
|
||||||
"h2":30,
|
|
||||||
"h3":90,
|
|
||||||
"h4":10,
|
|
||||||
"mortage":30,
|
|
||||||
"iins":50,
|
|
||||||
"group":1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
import arcade
|
|
||||||
import json
|
|
||||||
|
|
||||||
cards = list()
|
|
||||||
screen = (1280,768)
|
|
||||||
|
|
||||||
class Tile(arcade.Sprite):
|
|
||||||
ls = arcade.SpriteList()
|
|
||||||
def __init__(self,c):
|
|
||||||
super().__init__('./assets/blank.png', scale=1.0)
|
|
||||||
self.title = c['title']
|
|
||||||
self.text = arcade.Text(self.title,screen[0]//2,screen[1]//2,(0,0,0))
|
|
||||||
self.position = (screen[0]//2,screen[1]//2)
|
|
||||||
Tile.ls.append(self)
|
|
||||||
|
|
||||||
|
|
||||||
class MainView(arcade.View):
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__()
|
|
||||||
#self.background = arcade.load_texture("./assets/pole.png")
|
|
||||||
with open('cards.json','r',encoding='utf-8') as f:
|
|
||||||
cards = json.loads(f.read())
|
|
||||||
for c in cards:
|
|
||||||
Tile(c)
|
|
||||||
|
|
||||||
def on_draw(self):
|
|
||||||
self.clear((100,100,200))
|
|
||||||
Tile.ls.draw()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
window = arcade.Window(fullscreen=True)
|
|
||||||
screen = (window.width,window.height)
|
|
||||||
window.show_view(MainView())
|
|
||||||
arcade.run()
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
import arcade
|
|
||||||
from menu import MainMenu
|
|
||||||
|
|
||||||
class LogoView(arcade.View):
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__()
|
|
||||||
self.screen = (self.window.width,self.window.height)
|
|
||||||
self.logo = arcade.Sprite('./assets/logo.png',scale=1.0)
|
|
||||||
self.logo.position = (self.screen[0]//2,self.screen[1]//2)
|
|
||||||
self.logo.alpha = 0
|
|
||||||
self.logo.onshow = True
|
|
||||||
self.spl = arcade.SpriteList()
|
|
||||||
self.spl.append(self.logo)
|
|
||||||
|
|
||||||
def on_update(self,delta_time):
|
|
||||||
if self.logo.onshow:
|
|
||||||
self.logo.alpha += 127*delta_time
|
|
||||||
if self.logo.alpha >= 255:
|
|
||||||
self.logo.onshow = False
|
|
||||||
else:
|
|
||||||
self.logo.alpha -= 127*delta_time
|
|
||||||
if self.logo.alpha <= 0:
|
|
||||||
self.window.show_view(MainMenu())
|
|
||||||
def on_draw(self):
|
|
||||||
self.clear()
|
|
||||||
self.spl.draw()
|
|
||||||
@@ -1,7 +1,220 @@
|
|||||||
import arcade
|
import arcade
|
||||||
from logo import LogoView
|
from random import randint
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
SCREEN_SIZE = (800,600)
|
||||||
|
TICK_TIME = 0.5
|
||||||
|
|
||||||
|
class Wolf(arcade.SpriteCircle):
|
||||||
|
ls = arcade.SpriteList()
|
||||||
|
def __init__(self,parent=None):
|
||||||
|
super().__init__(radius=5, color=arcade.color.RED)
|
||||||
|
if parent:
|
||||||
|
self.center_x = parent.center_x
|
||||||
|
self.center_y = parent.center_y
|
||||||
|
else:
|
||||||
|
self.center_x = randint(1,SCREEN_SIZE[0])
|
||||||
|
self.center_y = randint(1,SCREEN_SIZE[1])
|
||||||
|
self.age = 0
|
||||||
|
self.age_to_bride = 3
|
||||||
|
self.health = 30
|
||||||
|
self.speed = 8
|
||||||
|
self.move_target = 0
|
||||||
|
self.target_timer = 0
|
||||||
|
Wolf.ls.append(self)
|
||||||
|
@classmethod
|
||||||
|
def update(cls):
|
||||||
|
if len(cls.ls) == 0:
|
||||||
|
Wolf()
|
||||||
|
for e in cls.ls:
|
||||||
|
e.age += 1
|
||||||
|
if e.age >= 30:
|
||||||
|
cls.ls.remove(e)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if e.health >= 50 and e.age_to_bride < e.age:
|
||||||
|
Wolf(e)
|
||||||
|
e.health -= 30
|
||||||
|
|
||||||
|
hit_cow = arcade.check_for_collision_with_list(e,Cow.ls)
|
||||||
|
for c in hit_cow:
|
||||||
|
e.health += c.health
|
||||||
|
Cow.ls.remove(c)
|
||||||
|
else:
|
||||||
|
if e.target_timer <= 0:
|
||||||
|
e.move_target = Cow.get_near(e.center_x,e.center_y)
|
||||||
|
e.target_timer = 3
|
||||||
|
if e.move_target:
|
||||||
|
vec = cls.get_vector(e.center_x,e.move_target.center_x,
|
||||||
|
e.center_y,e.move_target.center_y)
|
||||||
|
new_x = e.center_x + vec[0]*e.speed
|
||||||
|
new_y = e.center_y + vec[1]*e.speed
|
||||||
|
if 0 < new_x < SCREEN_SIZE[0] and 0 < new_y < SCREEN_SIZE[1]:
|
||||||
|
e.center_x = new_x
|
||||||
|
e.center_y = new_y
|
||||||
|
e.health -= 1
|
||||||
|
if e.health <= 0:
|
||||||
|
cls.ls.remove(e)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def draw(cls):
|
||||||
|
cls.ls.draw()
|
||||||
|
@staticmethod
|
||||||
|
def get_vector(src_x,target_x,src_y,target_y):
|
||||||
|
source = np.array([src_x, src_y])
|
||||||
|
target = np.array([target_x, target_y])
|
||||||
|
direction = target - source
|
||||||
|
length = np.linalg.norm(direction)
|
||||||
|
return direction / length
|
||||||
|
|
||||||
|
|
||||||
|
class Cow(arcade.SpriteCircle):
|
||||||
|
ls = arcade.SpriteList()
|
||||||
|
def __init__(self,parent=None):
|
||||||
|
super().__init__(radius=5, color=arcade.color.BROWN)
|
||||||
|
if parent:
|
||||||
|
self.center_x = parent.center_x
|
||||||
|
self.center_y = parent.center_y
|
||||||
|
else:
|
||||||
|
self.center_x = randint(1,SCREEN_SIZE[0])
|
||||||
|
self.center_y = randint(1,SCREEN_SIZE[1])
|
||||||
|
self.age = 0
|
||||||
|
self.age_to_bride = 3
|
||||||
|
self.health = 30
|
||||||
|
self.speed = 5
|
||||||
|
self.move_target = 0
|
||||||
|
self.target_timer = 0
|
||||||
|
Cow.ls.append(self)
|
||||||
|
@classmethod
|
||||||
|
def get_near(cls,x,y):
|
||||||
|
dist_list = list()
|
||||||
|
for e in cls.ls:
|
||||||
|
dist_list.append((e,((e.center_x - x)**2 + (e.center_y - y)**2)**0.5))
|
||||||
|
dist_list.sort(key=lambda x: x[1])
|
||||||
|
if len(dist_list) == 0:
|
||||||
|
return None
|
||||||
|
return dist_list[0][0]
|
||||||
|
@classmethod
|
||||||
|
def update(cls):
|
||||||
|
if len(cls.ls) == 0:
|
||||||
|
Cow()
|
||||||
|
for c in cls.ls:
|
||||||
|
c.age += 1
|
||||||
|
if c.age >= 30:
|
||||||
|
cls.ls.remove(c)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if c.health >= 50 and c.age_to_bride < c.age:
|
||||||
|
Cow(c)
|
||||||
|
c.health -= 30
|
||||||
|
|
||||||
|
hit_plant = arcade.check_for_collision_with_list(c,Plant.ls)
|
||||||
|
for p in hit_plant:
|
||||||
|
c.health += p.width
|
||||||
|
Plant.ls.remove(p)
|
||||||
|
else:
|
||||||
|
if c.target_timer <= 0:
|
||||||
|
c.move_target = Plant.get_near(c.center_x,c.center_y)
|
||||||
|
c.target_timer = 5
|
||||||
|
if c.move_target:
|
||||||
|
vec = cls.get_vector(c.center_x,c.move_target.center_x,
|
||||||
|
c.center_y,c.move_target.center_y)
|
||||||
|
new_x = c.center_x + vec[0]*randint(0,c.speed)
|
||||||
|
new_y = c.center_y + vec[1]*randint(0,c.speed)
|
||||||
|
if 0 < new_x < SCREEN_SIZE[0] and 0 < new_y < SCREEN_SIZE[1]:
|
||||||
|
c.center_x = new_x
|
||||||
|
c.center_y = new_y
|
||||||
|
c.health -= 1
|
||||||
|
if c.health <= 0:
|
||||||
|
cls.ls.remove(c)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def draw(cls):
|
||||||
|
cls.ls.draw()
|
||||||
|
@staticmethod
|
||||||
|
def get_vector(src_x,target_x,src_y,target_y):
|
||||||
|
source = np.array([src_x, src_y])
|
||||||
|
target = np.array([target_x, target_y])
|
||||||
|
direction = target - source
|
||||||
|
length = np.linalg.norm(direction)
|
||||||
|
return direction / length
|
||||||
|
|
||||||
|
class Plant(arcade.SpriteCircle):
|
||||||
|
ls = arcade.SpriteList()
|
||||||
|
|
||||||
|
def __init__(self,parent=None):
|
||||||
|
super().__init__(radius=1, color=arcade.color.GREEN)
|
||||||
|
if parent:
|
||||||
|
self.center_x = parent.center_x + randint(-parent.fly_distance,parent.fly_distance)
|
||||||
|
self.center_y = parent.center_y + randint(-parent.fly_distance,parent.fly_distance)
|
||||||
|
else:
|
||||||
|
self.center_x = randint(1,SCREEN_SIZE[0])
|
||||||
|
self.center_y = randint(1,SCREEN_SIZE[1])
|
||||||
|
self.age = 0
|
||||||
|
self.fly_distance = 100
|
||||||
|
self.age_to_plant = 10
|
||||||
|
if not arcade.check_for_collision_with_list(self,Plant.ls) and 0 < self.center_x < SCREEN_SIZE[0] and 0 < self.center_y < SCREEN_SIZE[1]:
|
||||||
|
Plant.ls.append(self)
|
||||||
|
@classmethod
|
||||||
|
def get_near(cls,x,y):
|
||||||
|
dist_list = list()
|
||||||
|
for p in cls.ls:
|
||||||
|
dist_list.append((p,((p.center_x - x)**2 + (p.center_y - y)**2)**0.5 - p.width ))
|
||||||
|
dist_list.sort(key=lambda x: x[1])
|
||||||
|
if len(dist_list) == 0:
|
||||||
|
return None
|
||||||
|
if len(dist_list) < 3:
|
||||||
|
return dist_list[0][0]
|
||||||
|
return dist_list[randint(0,3)][0]
|
||||||
|
@classmethod
|
||||||
|
def update(cls):
|
||||||
|
for p in cls.ls:
|
||||||
|
p.age += 1
|
||||||
|
hit_list = arcade.check_for_collision_with_list(p,cls.ls)
|
||||||
|
if p.center_x - p.width//2 > 0 and p.center_x + p.width//2 < SCREEN_SIZE[0] and p.center_y - p.height//2 > 0 and p.center_y + p.width//2 < SCREEN_SIZE[1] and not hit_list:
|
||||||
|
p.width += 2
|
||||||
|
p.height += 2
|
||||||
|
else:
|
||||||
|
for h in hit_list:
|
||||||
|
if p.width < h.width:
|
||||||
|
cls.ls.remove(p)
|
||||||
|
break
|
||||||
|
if p.age >= p.age_to_plant:
|
||||||
|
Plant(p)
|
||||||
|
@classmethod
|
||||||
|
def draw(cls):
|
||||||
|
cls.ls.draw()
|
||||||
|
for p in cls.ls:
|
||||||
|
p.draw_hit_box()
|
||||||
|
|
||||||
|
class MainView(arcade.View):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.background_color = (100,100,200)
|
||||||
|
Plant()
|
||||||
|
self.time = 0
|
||||||
|
self.cur_time = 0
|
||||||
|
self.text = None
|
||||||
|
|
||||||
|
def on_update(self, delta_time):
|
||||||
|
self.cur_time += delta_time
|
||||||
|
if self.cur_time >= TICK_TIME:
|
||||||
|
print(f'Total plants: {len(Plant.ls)}, total cows: {len(Cow.ls)}')
|
||||||
|
Plant.update()
|
||||||
|
Cow.update()
|
||||||
|
Wolf.update()
|
||||||
|
self.time += 1
|
||||||
|
self.cur_time = 0
|
||||||
|
|
||||||
|
def on_draw(self):
|
||||||
|
self.clear()
|
||||||
|
Plant.draw()
|
||||||
|
Cow.draw()
|
||||||
|
Wolf.draw()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
window = arcade.Window(fullscreen=True)
|
window = arcade.Window(*SCREEN_SIZE,"Игра про жизнь")
|
||||||
window.show_view(LogoView())
|
view = MainView()
|
||||||
|
window.show_view(view)
|
||||||
arcade.run()
|
arcade.run()
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
import arcade
|
|
||||||
from arcade.gui import UIManager, UIAnchorLayout, UITextureButton, UIGridLayout
|
|
||||||
from game import MainView
|
|
||||||
|
|
||||||
class MainMenu(arcade.View):
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
self.ui = UIManager()
|
|
||||||
grid = UIGridLayout(
|
|
||||||
column_count=1,
|
|
||||||
row_count=4,
|
|
||||||
size_hint=(0, 0),
|
|
||||||
vertical_spacing=10,
|
|
||||||
horizontal_spacing=10,
|
|
||||||
)
|
|
||||||
anchor = self.ui.add(UIAnchorLayout(children=[grid]))
|
|
||||||
normal = arcade.load_texture(":resources:gui_basic_assets/button/red_normal.png")
|
|
||||||
hover = arcade.load_texture(":resources:gui_basic_assets/button/red_hover.png")
|
|
||||||
press = arcade.load_texture(":resources:gui_basic_assets/button/red_press.png")
|
|
||||||
|
|
||||||
button_start = grid.add(UITextureButton(
|
|
||||||
text = "Start",
|
|
||||||
texture=normal,
|
|
||||||
texture_hovered=hover,
|
|
||||||
texture_pressed=press
|
|
||||||
),row=0,column=0)
|
|
||||||
button_exit = grid.add(UITextureButton(
|
|
||||||
text = "Exit",
|
|
||||||
texture=normal,
|
|
||||||
texture_hovered=hover,
|
|
||||||
texture_pressed=press
|
|
||||||
),row=1,column=0)
|
|
||||||
|
|
||||||
@button_start.event('on_click')
|
|
||||||
def on_click(event):
|
|
||||||
self.window.show_view(MainView())
|
|
||||||
|
|
||||||
@button_exit.event('on_click')
|
|
||||||
def on_click(event):
|
|
||||||
self.window.close()
|
|
||||||
|
|
||||||
def on_show_view(self):
|
|
||||||
self.ui.enable()
|
|
||||||
|
|
||||||
def on_hide_view(self):
|
|
||||||
self.ui.disable()
|
|
||||||
|
|
||||||
def on_draw(self):
|
|
||||||
self.clear((100,100,200))
|
|
||||||
self.ui.draw()
|
|
||||||
if __name__ == '__main__':
|
|
||||||
window = arcade.Window(fullscreen=True)
|
|
||||||
window.show_view(MainMenu())
|
|
||||||
arcade.run()
|
|
||||||