Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. class Vector(cx: Int, cy: Int) {
  2. def x = cx
  3. def y = cy
  4. }
  5.  
  6. class Sprite(filename: String) {
  7. }
  8.  
  9. trait TPosition {
  10. def position: Vector
  11. }
  12.  
  13. trait TSprite {
  14. def sprite: Sprite
  15.  
  16. def render() {
  17. println("sprite.render")
  18. }
  19. }
  20.  
  21. abstract class Entity {
  22. def name: String
  23. def update
  24. }
  25.  
  26. class Player(cname: String) extends Entity with TPosition with TSprite {
  27. val name = cname
  28. val position = new Vector(0, 0)
  29. val sprite = new Sprite("assets/sprites/player.json")
  30.  
  31. def update() {
  32. println("player.update")
  33. }
  34. }
  35.  
  36. object Main {
  37. def main(args: Array[String]) {
  38. var p = new Player("Player")
  39.  
  40. p.update
  41. p.render
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement