-
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
65 changed files
with
2,897 additions
and
4,773 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ export default { | |
singleQuote: true, | ||
jsxSingleQuote: true, | ||
arrowParens: 'avoid', | ||
printWidth: 200, | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,4 @@ | ||
import type { ComponentPropsWithoutRef as ComponentProps } from 'react' | ||
import NextImage from 'next/image' | ||
|
||
export const Image = ({ | ||
style, | ||
...props | ||
}: ComponentProps<typeof NextImage>) => ( | ||
<NextImage | ||
style={{ marginTop: '1.25rem', borderRadius: '.5rem', ...style }} | ||
{...props} | ||
/> | ||
) | ||
export const Image = ({ style, ...props }: ComponentProps<typeof NextImage>) => <NextImage style={{ marginTop: '1.25rem', borderRadius: '.5rem', ...style }} {...props} /> |
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 |
---|---|---|
@@ -1,14 +1,7 @@ | ||
import { ComponentPropsWithoutRef as ComponentProps } from 'react' | ||
|
||
export const Tooltip = ({ | ||
children, | ||
style, | ||
...props | ||
}: ComponentProps<'span'> & { readonly title: string }) => ( | ||
<span | ||
style={{ ...style, borderBottom: '1px dotted currentColor' }} | ||
{...props} | ||
> | ||
export const Tooltip = ({ children, style, ...props }: ComponentProps<'span'> & { readonly title: string }) => ( | ||
<span style={{ ...style, borderBottom: '1px dotted currentColor' }} {...props}> | ||
{children} | ||
</span> | ||
) |
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 |
---|---|---|
@@ -1,6 +1,23 @@ | ||
import { Callout } from 'nextra/components' | ||
import { Image } from '~/components/image' | ||
import scriptsTab from '~/assets/images/scriptstab.png' | ||
|
||
export const UnderConstruction = () => ( | ||
<Callout type='info'>This docs page is under construction. Expect more information coming to this page soon!<br></br> | ||
If you have questions, please ask them in our <u><a href="https://discord.gg/nwXFvtJ92g">Discord server</a></u> and we'll answer them promptly! 😊</Callout> | ||
<Callout type='info'> | ||
This docs page is under construction. Expect more information coming to this page soon!<br></br> | ||
If you have questions, please ask them in our{' '} | ||
<u> | ||
<a href='https://discord.gg/nwXFvtJ92g'>Discord server</a> | ||
</u>{' '} | ||
and we'll answer them promptly! 😊 | ||
</Callout> | ||
) | ||
|
||
export const AIDocs = () => ( | ||
<Callout type='info'> | ||
These docs are written to be queried by the Dreamlab Assistant, our chatbot that helps you code your game. | ||
<Image src={scriptsTab} style={{ width: 'auto', maxHeight: '15rem' }} alt='scripts tab location'></Image> | ||
<br></br> | ||
Navigate to your "Scripts" tab as shown and the Dreamlab Assistant will be available on the right side. | ||
</Callout> | ||
) |
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,74 @@ | ||
// This is an example of how to implement a platformer controller using the KinematicCharacterController | ||
|
||
import { Behavior, EntityDestroyed, RectCollider, Vector2 } from '@dreamlab/engine' | ||
import { KinematicCharacterController } from '@dreamlab/vendor/rapier.ts' | ||
|
||
export default class PlatformMovement extends Behavior { | ||
#collider: RectCollider = this.entity.cast(RectCollider) | ||
#controller: KinematicCharacterController | undefined | ||
|
||
speed = 10.0 | ||
jumpForce = 20.0 | ||
jumpAcceleration = 40 | ||
gravity = 90.0 | ||
maxJumpTime = 1 // Maximum duration the jump key affects the jump | ||
|
||
#verticalVelocity = 0 | ||
#isGrounded = false | ||
#jumpTimeCounter = 0 | ||
|
||
#up = this.inputs.create('@movement/up', 'Move Up', 'KeyW') | ||
#down = this.inputs.create('@movement/down', 'Move Down', 'KeyS') | ||
#left = this.inputs.create('@movement/left', 'Move Left', 'KeyA') | ||
#right = this.inputs.create('@movement/right', 'Move Right', 'KeyD') | ||
#jump = this.inputs.create('@movement/jump', 'Jump', 'Space') | ||
|
||
setup() { | ||
this.defineValues(PlatformMovement, 'speed', 'jumpForce', 'jumpAcceleration', 'gravity', 'maxJumpTime') | ||
} | ||
|
||
onInitialize(): void { | ||
if (this.game.isClient()) { | ||
this.#controller = this.game.physics.world.createCharacterController(0.01) | ||
} | ||
|
||
this.listen(this.entity, EntityDestroyed, () => { | ||
if (this.#controller) this.game.physics.world.removeCharacterController(this.#controller) | ||
}) | ||
} | ||
|
||
onTick(): void { | ||
if (!this.#controller) return | ||
|
||
const deltaTime = this.game.physics.tickDelta / 1000 // Convert to seconds | ||
|
||
let horizontalInput = 0 | ||
if (this.#right.held) horizontalInput += 1 | ||
if (this.#left.held) horizontalInput -= 1 | ||
|
||
const horizontalVelocity = horizontalInput * this.speed | ||
|
||
// Jumping logic | ||
if (this.#jump.pressed && this.#isGrounded) { | ||
this.#verticalVelocity = this.jumpForce | ||
this.#jumpTimeCounter = 0 | ||
} | ||
|
||
if (this.#jump.held && this.#jumpTimeCounter < this.maxJumpTime) { | ||
// Apply upward acceleration while the jump key is held | ||
this.#verticalVelocity += this.jumpAcceleration * deltaTime | ||
this.#jumpTimeCounter += deltaTime | ||
} | ||
|
||
// Create movement vector | ||
const movement = new Vector2(horizontalVelocity * deltaTime, this.#verticalVelocity * deltaTime) | ||
|
||
this.#controller.computeColliderMovement(this.#collider.collider, movement) | ||
const corrected = this.#controller.computedMovement() | ||
|
||
this.#isGrounded = this.#controller.computedGrounded() | ||
if (!this.#isGrounded) this.#verticalVelocity -= this.gravity * deltaTime | ||
|
||
this.entity.pos = this.entity.pos.add(corrected) | ||
} | ||
} |
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
Oops, something went wrong.