added manyloc test suite; --path now relative to project dir if not absolute
This commit is contained in:
parent
4f09794be9
commit
75b508032b
51 changed files with 9286 additions and 5 deletions
34
tests/manyloc/keineschweine/lib/game_objects.nim
Normal file
34
tests/manyloc/keineschweine/lib/game_objects.nim
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import chipmunk, sfml, animations, sg_assets
|
||||
type
|
||||
PGameObject* = ref TGameObject
|
||||
TGameObject = object
|
||||
body*: chipmunk.PBody
|
||||
shape*: chipmunk.PShape
|
||||
record*: PObjectRecord
|
||||
anim*: PAnimation
|
||||
|
||||
|
||||
proc `$`*(obj: PGameObject): string =
|
||||
result = "<Object "
|
||||
result.add obj.record.name
|
||||
result.add ' '
|
||||
result.add($obj.body.getpos())
|
||||
result.add '>'
|
||||
proc free(obj: PGameObject) =
|
||||
obj.record = nil
|
||||
free(obj.anim)
|
||||
obj.anim = nil
|
||||
proc newObject*(record: PObjectRecord): PGameObject =
|
||||
if record.isNil: return nil
|
||||
new(result, free)
|
||||
result.record = record
|
||||
result.anim = newAnimation(record.anim, AnimLoop)
|
||||
when false:
|
||||
result.sprite = record.anim.spriteSheet.sprite.copy()
|
||||
result.body = newBody(result.record.physics.mass, 10.0)
|
||||
result.shape = chipmunk.newCircleShape(result.body, result.record.physics.radius, vectorZero)
|
||||
result.body.setPos(vector(100, 100))
|
||||
proc newObject*(name: string): PGameObject =
|
||||
result = newObject(fetchObj(name))
|
||||
proc draw*(window: PRenderWindow, obj: PGameObject) {.inline.} =
|
||||
window.draw(obj.anim.sprite)
|
||||
Loading…
Add table
Add a link
Reference in a new issue