forked from migueldeicaza/SwiftGodot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
144 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
Sources/SwiftGodot/SwiftGodot.docc/Resources/Tutorials/Sources/SwiftGodotKit-Main.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// main.swift | ||
// SimpleGodotApp | ||
// | ||
// Created by Miguel de Icaza on 9/6/23. | ||
// | ||
|
||
import Foundation | ||
import SwiftGodotKit | ||
import SwiftGodot | ||
|
||
|
||
func loadScene (scene: SceneTree) { | ||
let rootNode = Node3D() | ||
let camera = Camera3D () | ||
camera.current = true | ||
camera.position = Vector3(x: 0, y: 0, z: 2) | ||
|
||
rootNode.addChild(node: camera) | ||
|
||
func makeCuteNode (_ pos: Vector3) -> Node { | ||
let n = SpinningCube() | ||
n.position = pos | ||
return n | ||
} | ||
rootNode.addChild(node: makeCuteNode(Vector3(x: 1, y: 1, z: 1))) | ||
rootNode.addChild(node: makeCuteNode(Vector3(x: -1, y: -1, z: -1))) | ||
rootNode.addChild(node: makeCuteNode(Vector3(x: 0, y: 1, z: 1))) | ||
scene.root?.addChild(node: rootNode) | ||
} | ||
|
||
|
||
class SpinningCube: Node3D { | ||
required init (nativeHandle: UnsafeRawPointer) { | ||
super.init (nativeHandle: nativeHandle) | ||
} | ||
|
||
required init () { | ||
super.init () | ||
let meshRender = MeshInstance3D() | ||
meshRender.mesh = BoxMesh() | ||
addChild(node: meshRender) | ||
} | ||
|
||
override func _input (event: InputEvent) { | ||
guard event.isPressed () && !event.isEcho () else { return } | ||
print ("SpinningCube: event: isPressed ") | ||
} | ||
|
||
public override func _process(delta: Double) { | ||
rotateY(angle: delta) | ||
} | ||
} | ||
|
||
func registerTypes (level: GDExtension.InitializationLevel) { | ||
switch level { | ||
case .scene: | ||
register (type: SpinningCube.self) | ||
default: | ||
break | ||
} | ||
} | ||
|
||
runGodot(args: [], initHook: registerTypes, loadScene: loadScene, loadProjectSettings: { settings in }) |
Binary file added
BIN
+983 KB
...ources/Tutorials/SwiftGodotKitImages/SwiftGodotKit-Xcode-1-MacOS-NewProject.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.6 MB
...cc/Resources/Tutorials/SwiftGodotKitImages/SwiftGodotKit-Xcode-2-AddPackage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.7 MB
...occ/Resources/Tutorials/SwiftGodotKitImages/SwiftGodotKit-Xcode-3-AddTarget.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.63 MB
...sources/Tutorials/SwiftGodotKitImages/SwiftGodotKit-Xcode-4-HardenedRuntime.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+645 KB
...t.docc/Resources/Tutorials/SwiftGodotKitImages/SwiftGodotKit-Xcode-5-Sample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
Sources/SwiftGodot/SwiftGodot.docc/Tutorials/Using Swift Godot Kit.tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
@Tutorial(time: 5) { | ||
@Intro(title: "Using SwiftGodotKit") { | ||
SwiftGodotKit lets you drive Godot entirely from Swift, and treat Godot as just another Swift framework you can call into. | ||
|
||
@Image(source: "RunnerHeader.png", | ||
alt: "A screenshot of the Simple Runner game. The player wears a bird costume and runs alongside boxes.") | ||
} | ||
|
||
@Section(title: "SwiftGodotKit from Xcode") { | ||
@ContentAndMedia { | ||
Using Godot as a library using SwiftGodotKit | ||
} | ||
|
||
@Steps { | ||
@Step { | ||
In Xcode, create a new project. In our example, we are going to create a new MacOS project and make this a command line tool. You can use other options, but this shows the most minimal project you can create. | ||
|
||
@Image(source: "SwiftGodotKit-Xcode-1-MacOS-NewProject.png", | ||
alt: "Xcode New MacOS Project dialog showing a Command Line Tool") | ||
} | ||
@Step { | ||
You will now Add a dependency on the `SwiftGodotKit` library. | ||
} | ||
|
||
@Step { | ||
To do this, after you create your project, select your project from the navigator, and go to "Package Dependencies". There click the "+" button and when the package selector comes up, enter the URL for the SwiftGodotKit package: https://github.com/migueldeicaza/SwiftGodotKit | ||
|
||
@Image(source: "SwiftGodotKit-Xcode-2-AddPackage.png", | ||
alt: "Adding the package to the project") | ||
} | ||
|
||
@Step { | ||
The SwiftGodotKit package comes with various samples, you only need the SwiftGodotKit package to be added to your project, so you can safely set all the Package Products to "None" in the "Add to Target" column | ||
|
||
@Image(source: "SwiftGodotKit-Xcode-3-AddTarget.png", | ||
alt: "Dialog showing which package products are available from SwiftGodotKit") | ||
} | ||
|
||
@Step { | ||
Since this contains a native library that has not been signed, go to your "Signing & Capabilities" tab for your target, and in the "Hardened Runtime" which is checked-in by default, enable the "Disable Library Validation". Alternatively, you can remove the "Hardened Runtime". | ||
|
||
@Image(source: "SwiftGodotKit-Xcode-4-HardenedRuntime.png", | ||
alt: "Two Finder windows that show the dynamic library files being copied to the game's files.") | ||
} | ||
|
||
@Step { | ||
You can now enter a sample SwiftGodot project. This needs to import both the `SwiftGodotKit` API which provides one entry point: the `runGodot` method, and the `SwiftGodot` API, that contains the bulk of the code. | ||
|
||
@Code(name: "SwiftGodotKit-Main.swift", | ||
file: "SwiftGodotKit-Main.swift") | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters