main.nim 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 .. ?", GONE),
  11. ("Eileen", "NANI??????", VISIBLE)
  12. ]
  13. stage = 0
  14. build:
  15. - Scene main:
  16. call rename("Main")
  17. - Button button:
  18. call setText("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. visibility: GONE
  34. - Label dialog_text:
  35. call setSizeAnchor(0.8, 0.3)
  36. call setAnchor(0.1, 0.6, 0, 0)
  37. call setBackgroundColor(Color(0x0e131760))
  38. call setPadding(8, 8, 8, 8)
  39. - Label name_charapter:
  40. call resize(128, 32)
  41. call setAnchor(0, 0, 0, 1)
  42. call setBackgroundColor(Color(0x0e131760'u32))
  43. call setStyle(style({
  44. border-radius: "8 8 0 0"
  45. }))
  46. call setTextAlign(0.1, 0.5, 0.1, 0.5)
  47. - ColorRect foreground_rect:
  48. call setSizeAnchor(1, 1)
  49. color: Color(0x0e1317ff)
  50. - AnimationPlayer animation:
  51. loop: false
  52. call addState(foreground_rect.color.a.addr,
  53. @[(tick: 0, value: 1.0), (tick: 100, value: 0.0)])
  54. foreground_rect@on_ready(self):
  55. animation.play()
  56. foreground_rect@on_input(self, event):
  57. if event.isInputEventMouseButton() and not event.pressed:
  58. if stage < dialog.len():
  59. name_charapter.setText(dialog[stage][0])
  60. dialog_text.setText(dialog[stage][1])
  61. charapter.visibility = dialog[stage][2]
  62. inc stage
  63. button.on_touch =
  64. proc(self: ButtonRef, x, y: float) =
  65. changeScene("Game")
  66. addMainScene(main)
  67. addScene(game_scene)
  68. windowLaunch()