Skip to content

Commit

Permalink
Added Initialization.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mastercuber55 committed Oct 22, 2023
1 parent c5b317f commit 7263d7c
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/Creating A Game/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ var Path = {
"SceneError": "Scenes/SceneError.wren"
}
```

As for the current version, it is a absolute must that you have a file named Game.wren in same folder as Cube2D executable or it will crash but sooner or later we will make it so that the engine lets you know that no Game.wren was found atleast.
55 changes: 55 additions & 0 deletions docs/Creating A Game/Initialization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: Initialization
layout: default
parent: Creating A Game
nav_order: 2
---

# Initialization

Any projects needs a initializer of its own, so create a file in your desired scripts folder with your desired name ( I Like Scripts/Main.wren)

For now, lets make a simple game where you have to move player around.

```js
// File: Main.wren
import "raylib" for COLOR
import "Cube2D" for Engine, Scene, Rect

class SceneGame is Scene {
construct new() {
_Player = Rect.new(0, 0, 32, 32)
_Player.Tint = COLOR["RED"]

super()
}
Update() {
var Speed = 10
// We are still too busy to look into why we use .Base here.
Engine.WASDMovement(_Player.Base, Speed)
}
Draw() {
_Player.Draw()
}
}

SceneGame.new().Run()

```

Very Minimal, but you can do a lots of initialization stuff for your game like loading config files etc.
speaking of loading config files, you surely want some sort of configuration data saving file etc.
And Cube2D Engine provides nothing of a sort but there's a alternative that takes no time at all to setup.
We will look into that later though, cuz can't start compilacated stuff even before you know anything.


You can also use that file as following supposing that file is located at `Scripts/Scenes/SceneGame.wren`
```js
// File: Main.wren
import "Scenes/SceneGame.wren" for SceneGame

SceneGame.new().Run()

```

As you see you are importing `SceneGame` only not the whole file so any code in that file won't be ran
13 changes: 12 additions & 1 deletion docs/Wren.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Installation
title: Wren
layout: default
nav_order: 3
---
Expand Down Expand Up @@ -76,6 +76,9 @@ import "Scenes/SceneTitle" for SceneGame
// As you see, .wren is optional for my engine.
```

{: .note }
`import` statement in my engine doesn't look for modules from the current file location instead it looks for modules in configured folder in `Game.wren`

### Classes

```js
Expand All @@ -98,5 +101,13 @@ class Entity is Rect {
}
```

### So Why Did We Choose Wren?

- Dynamic Typing
- No Semicolons
- Fast
- Modular
- Classes
- Inheritance

[wren]: https://wren.io
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Cube2D Engine, A minimal 2D simple and easy to use game development engine that
- Simple And Easy To Use
- Highly Customizable
- Utilizes [wren] as its scripting language.
- Binds all of [raylib], [raymath], [Cube2D Framework]
- Binds almost all of [raylib], [raymath], [Cube2D Framework]
- Automatic asset management using [Cube2D Framework]
- Scene Management using [Cube2D Framework]

Expand Down

0 comments on commit 7263d7c

Please sign in to comment.