Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
blueloveTH committed Aug 19, 2023
1 parent 83e062b commit 3707907
Showing 1 changed file with 0 additions and 52 deletions.
52 changes: 0 additions & 52 deletions workdir/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,6 @@

sounds = []

class Sprite(Node):
def on_render(self):
pass

class Player(Node):
def on_ready(self):
self.tex = load_texture('assets/kenney_simple-space/ship_G.png')
self.speed = 1
self.b2_body = self.create_body()
# self.b2_body.set_circle_shape(0.5 * self.scale.x)
self.b2_body.set_box_shape(0.5 * self.scale.x, 0.5 * self.scale.y)
# self.b2_body.velocity = vec2(-1, 0)

def on_render(self):
# 渲染逻辑
draw_sprite(self.transform(), self.tex)

def on_update(self):
# 更新逻辑
dt = ImGui.GetIO().DeltaTime
axis = vec2(0, 0)
if ImGui.IsKeyDown(ImGui.ImGuiKey_W):
axis.y -= 1
if ImGui.IsKeyDown(ImGui.ImGuiKey_S):
axis.y += 1
if ImGui.IsKeyDown(ImGui.ImGuiKey_A):
axis.x -= 1
if ImGui.IsKeyDown(ImGui.ImGuiKey_D):
axis.x += 1
if axis != vec2(0, 0):
axis = axis.normalize()
self.b2_body.velocity = axis * self.speed
# else:
# self.b2_body.velocity = vec2(0, 0)

def on_contact_begin(self, other):
print('contact begin', other)

def on_contact_end(self, other):
print('contact end', other)


class Ball(Node):
def on_ready(self):
self.tex = load_texture('assets/circle_64x64.png')
Expand All @@ -73,7 +31,6 @@ def on_box2d_post_step(self):
self.rotation = self.b2_body.rotation



class Cell:
def __init__(self, tex, tint_col: vec4):
if tex is None:
Expand Down Expand Up @@ -128,15 +85,6 @@ def on_contact_begin(self, other):
'g|Ground': {
'_': {'position': vec2(-2, -1)},
},
# 'player|Player': {
# # '_': {'scale': vec2(1, 1)*0.4, 'position': vec2(2.2, 0.8)},
# '_': {'scale': vec2(1, 1)*0.4, 'position': vec2(1, -3)},
# },
# 'child|Sprite': {
# '_': {'scale': vec2(1, 1)*0.5},
# 'child1|Sprite': None,
# 'child2|Sprite': None,
# },
}

build_scene_tree(tree, globals())

0 comments on commit 3707907

Please sign in to comment.