Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaxkr committed May 21, 2024
1 parent d325bd4 commit a0d5bc9
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 98 deletions.
Binary file added assets/images/characters_demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion components/under-construction.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Callout } from 'nextra/components'

export const UnderConstruction = () => (
<Callout type='info'>This page is under construction.</Callout>
<Callout type='info'>This page is under construction. More information coming soon! If you have any questions, please ask them in our <u><a href="https://discord.gg/nwXFvtJ92g">Discord server</a></u> and we'll answer them promptly! 😊</Callout>
)
1 change: 0 additions & 1 deletion pages/asset-creator/_meta.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export default {
characters: 'Characters',
platforms: 'Platforms',
props: 'Props',
scenery: 'Create from a Sketch',
}
40 changes: 6 additions & 34 deletions pages/asset-creator/characters.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { UnderConstruction } from '~/components/under-construction'
import { Image } from '~/components/image'

# Characters
import CharactersDemo from '~/assets/images/characters_demo.png'

<UnderConstruction />
# Characters

Dreamlab's character generator is used to create animated sprites.

Expand All @@ -12,36 +12,8 @@ It has the following components:
- Animations. Animation files using the Mixamo bone convention that are used to drive rigs.
- AI Painter. Generates 2D sprites for each frame of an animation.

## Prompting

{
// This doesn't work so I'm removing it

// ### Concept Isolation

// Dreamlab allows you to associate certain words with certain objects explicitly.

// For example, this prompt may lead to colors bleeding across concepts (black applies to pants, green applies to background or shoes, etc.):

// `// man wearing a black jacket, blue pants, green baseball cap
//`

// We can see that in this result:
// video here

// However, we can rewrite our prompt like this:

// `// man wearing a [black: jacket], [blue: pants], [green: baseball cap]
//`

// video here

// Here's another example:

// `// knight wearing armor, red helmet, black chestplate full body
//`
## How To Use

// ...
<Image src={CharactersDemo} alt='Demo of character creator.' />

// This solves the problem of having color bleed into the rest of your image.
}
To generate an animated character, simply enter your prompt, select your skeleton, and press "Generate Preview"! Once you're happy with your creation, you can click "Generate Full Animation" to generate a complete set of spritesheets for all animations.
7 changes: 0 additions & 7 deletions pages/asset-creator/platforms.mdx

This file was deleted.

7 changes: 0 additions & 7 deletions pages/concepts/animated-sprites.mdx

This file was deleted.

6 changes: 1 addition & 5 deletions pages/concepts/entities.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ import { UnderConstruction } from '~/components/under-construction'
In Dreamlab, an entity is a distinct object that can be created, updated, or destroyed.
They can respond to events such as physics ticks or network packets and run logic in the game world.

<Callout>
You will most likely not want to work with Entities directly. Dreamlab has an
abstraction called Spawnable Entities that you should use to represent objects
in the world.
</Callout>
To implement objects in the world, you inherit from the SpawnableEntity class.

## Spawnable Entities

Expand Down
2 changes: 1 addition & 1 deletion pages/concepts/physics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { UnderConstruction } from '~/components/under-construction'

## Detecting Collisions

## Importing Modules from Matter.js
## Importing from Matter.js

If you want to import a specific class from Matter, you cannot use the normal import syntax:

Expand Down
13 changes: 6 additions & 7 deletions pages/concepts/ui.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ care of all the UI setup and state tracking for you.
[source](https://github.com/WorldQL/dreamlab-ui/tree/trunk/src/react/hooks).
</Callout>

| Hook Signature | Description |
| ---------------------------------------------------- | --------------------------------------------------------------------- |
| `useGame(): Game` | Returns a reference to the current `Game` |
| `usePlayer(): Player` | Returns a reference to the player |
| `useCamera(): Camera` | Returns a reference to the camera |
| `useEntities(): readonly Entity[]` | Returns a list of all current entities (including spawnable entities) |
| `useSpawnableEntities(): readonly SpawnableEntity[]` | Returns a list of **only** spawnable entities |
| Hook Signature | Description |
| ---------------------------------------------------- | --------------------------------------------- |
| `useGame(): Game` | Returns a reference to the current `Game` |
| `usePlayer(): Player` | Returns a reference to the player |
| `useCamera(): Camera` | Returns a reference to the camera |
| `useSpawnableEntities(): readonly SpawnableEntity[]` | Returns a list of **only** spawnable entities |

## Styling

Expand Down
72 changes: 68 additions & 4 deletions pages/extra/common-patterns.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,72 @@ import { UnderConstruction } from '~/components/under-construction'

# Common Patterns

<UnderConstruction />
## Disabling the default character controller

Dreamlab's built-in 2D platformer controller is a special entity that is automatically initialized.
To disable it, you can use the code below. This snippet is already included in any template that overrides the default character controller.

```ts filename="shared.ts"
import { disableDefaultPlatformController } from './util.ts'
export const sharedInit: InitShared = game => {
// disable default character controller
disableDefaultPlatformController()
}
```

```ts filename="client.ts"
import { setDefaultPlayerCameraTarget } from './util.ts'

// if you want to have the camera automatically track your custom controller, you can do use the following pattern
const player = game.spawn({
// ...
}) as MyCustomPlayerController

const camera = game.client.render.camera
setDefaultPlayerCameraTarget(player)
```

- wait for player
- styled components
- probably more
```ts filename="util.ts"
import { SpawnableEntity } from '@dreamlab.gg/core'
import { Player, isNetPlayer, isPlayer } from '@dreamlab.gg/core/entities'
import { game } from '@dreamlab.gg/core/labs'

export const disableDefaultPlatformController = () => {
const server = game('server')
const client = game('client')
if (server) {
server.events.common.addListener('onInstantiate', entity => {
if (isNetPlayer(entity)) {
entity.body.isSensor = true
}
})
}
if (client) {
client.events.common.addListener('onInstantiate', entity => {
if (isNetPlayer(entity)) client.destroy(entity)
if (isPlayer(entity)) {
client.destroy(entity)
Player.unregisterInputs()
}
})
}
}

export const setDefaultPlayerCameraTarget = (e: SpawnableEntity) => {
const camera = game('client')?.client.render.camera
if (!camera) return

camera.target = e
camera.defaultPlayerEntity = e
game('client')?.events.common.addListener('onInstantiate', entity => {
// if a default player entity spawns, reset the target back to ours
if (isPlayer(entity)) {
camera.target = e
// defaultPlayerEntity defines the entity that's automatically moved when you pan in the level editor
camera.defaultPlayerEntity = e
}
})
}
```

<UnderConstruction />
31 changes: 0 additions & 31 deletions pages/extra/templates.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,6 @@ import { Callout } from 'nextra/components'

# Templates

## Blank Entity

<Callout>
See the concepts page for [Entities](../concepts/entities.mdx) for the
difference between **Entities** and **_Spawnable_ Entitites**.
</Callout>

```ts filename="TypeScript" showLineNumbers
import { Entity } from '@dreamlab.gg/core'

export class ExampleEntity extends Entity {
public constructor() {
super()

// initialize entity resources
}

public teardown(): void {
// free any used resources (eg: graphics primitives)
}

public override onPhysicsStep(time: Time): void {
// ...
}

public override onRenderFrame(time: RenderTime): void {
// ...
}
}
```

## Blank Spawnable Entity

```ts filename="TypeScript" showLineNumbers
Expand Down

0 comments on commit a0d5bc9

Please sign in to comment.