MCAce commited on
Commit
f3382b1
·
verified ·
1 Parent(s): 0988e96

Create Example

Browse files
Files changed (1) hide show
  1. Example +32 -0
Example ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ local Avatar = require("Avatar")
2
+
3
+ local player = Avatar:new{
4
+ name = "Sven",
5
+ x = 100,
6
+ y = 100,
7
+ speed = 150,
8
+ frameSpeed = 0.08,
9
+ sprite = nil, -- später Sprite-Objekt setzen
10
+ animations = {
11
+ -- z.B. "walk_down" = {quad1, quad2, quad3, ...}
12
+ }
13
+ }
14
+
15
+ -- In deinem Update-Loop
16
+ function update(dt)
17
+ local dx, dy = 0, 0
18
+
19
+ -- Beispiel Input (Pseudo-Code)
20
+ if isKeyDown("left") then dx = dx - 1 end
21
+ if isKeyDown("right") then dx = dx + 1 end
22
+ if isKeyDown("up") then dy = dy - 1 end
23
+ if isKeyDown("down") then dy = dy + 1 end
24
+
25
+ player:move(dx, dy, dt)
26
+ player:update(dt)
27
+ end
28
+
29
+ -- In deinem Render-Loop
30
+ function draw()
31
+ player:draw()
32
+ end