- new Point3d[Float](center.x & force, center.y & force/2.0, center.z & force),
- (4096.0 & 2048.0) * force, 0.3 & 0.3, 0.5.rand)
- end
- end
-end
-
-redef class Int
- # Pad a number with `0`s on the left side to reach `size` digits
- private fun pad(size: Int): String
- do
- var s = to_s
- var d = size - s.length
- if d > 0 then s = "0"*d + s
- return s
- end
-end
-
-# Special `Sprite` for the player character which is animated
-class PlayerSprite
- super Sprite
-
- # Animation of the running character
- var running_animation: Array[Texture]
-
- # Seconds per frame of the animations
- var time_per_frame: Float
-
- # Currently playing animation
- private var current_animation: nullable Array[Texture] = null
-
- # Second at witch `current_animation` started
- private var anim_ot = 0.0
-
- # Start the running animation
- fun start_running
- do
- anim_ot = app.world.t
- current_animation = running_animation
- end
-
- # Stop the running animation
- fun stop_running do current_animation = null
-
- # Update `texture` from `current_animation`
- fun update
- do
- var anim = current_animation
- if anim != null then
- var dt = app.world.t - anim_ot
- var i = (dt / time_per_frame).to_i+2
- texture = anim.modulo(i)
+ new Point3d[Float](center.x & range, center.y & range, center.z & range),
+ (2048.0 & 1024.0) * force, 0.3 & 0.3, 0.5.rand)