main.nim 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # main scene
  2. import nodesnim
  3. Window("Novel game", 1280, 720)
  4. var
  5. # Backgrounds:
  6. night = load("assets/night.jpg")
  7. # Charapters:
  8. akiko_default = load("assets/test.png", GL_RGBA)
  9. dialog = @[
  10. ("Me", "H-Hey .. ?", false),
  11. ("Eileen", "NANI??????", true)
  12. ]
  13. stage = -1
  14. build:
  15. - Scene main:
  16. call rename("Main")
  17. - Button button:
  18. text: "New game"
  19. call resize(128, 32)
  20. call setAnchor(0.5, 0.5, 0.5, 0.5)
  21. - Scene game_scene:
  22. call rename("Game")
  23. - TextureRect background_image:
  24. call setSizeAnchor(1, 1)
  25. call setTexture(night)
  26. call setTextureAnchor(0.5, 0.5, 0.5, 0.5)
  27. texture_mode: TEXTURE_KEEP_ASPECT_RATIO
  28. - TextureRect charapter:
  29. call setSizeAnchor(1, 1)
  30. call setTexture(akiko_default)
  31. call setTextureAnchor(0.5, 0.5, 0.5, 0.5)
  32. texture_mode: TEXTURE_KEEP_ASPECT_RATIO
  33. visible: false
  34. - RichLabel dialog_text:
  35. call setSizeAnchor(0.8, 0.3)
  36. call setAnchor(0.1, 0.6, 0, 0)
  37. call setBackgroundColor(Color(0x0e131760))
  38. - Label name_charapter:
  39. call resize(128, 32)
  40. call setAnchor(0, 0, 0, 1)
  41. call setStyle(style({background-color: "#0e131760", border-radius: 8}))
  42. call setTextAlign(0.1, 0.5, 0.1, 0.5)
  43. - ColorRect foreground_rect:
  44. call setSizeAnchor(1, 1)
  45. color: Color(0x0e1317ff)
  46. - AnimationPlayer animation:
  47. loop: false
  48. call addState(foreground_rect.color.a.addr,
  49. @[(tick: 0, value: 1.0), (tick: 100, value: 0.0)])
  50. foreground_rect@on_ready(self):
  51. animation.play()
  52. foreground_rect@on_input(self, event):
  53. if event.isInputEventMouseButton() and not event.pressed:
  54. inc stage
  55. if stage < dialog.len():
  56. name_charapter.setText(dialog[stage][0])
  57. dialog_text.setText(clrtext(dialog[stage][1]))
  58. charapter.visible = dialog[stage][2]
  59. button.on_touch =
  60. proc(self: ButtonRef, x, y: float) =
  61. changeScene("Game")
  62. echo main.name, ", ", game_scene.name
  63. addMainScene(main)
  64. addScene(game_scene)
  65. windowLaunch()