Code Monkey home page Code Monkey logo

decentralandcreeps's Introduction

Decentraland Tower Defense Game

This is a simple tower defense game for Decentraland.

The game generates a random path and places traps in random locations along that path. Then enemy entities are spawn and follow this path, unless you activate the traps to stop them. The game supports multiple players, has a scoreboard and has a reset button to restart the game at any time.

Getting Started

Install Decentraland with:

npm install -d decentraland

Clone this repository and then in the project's directory run:

dcl start

This will open a browser tab with the game.

Tutorial

Written: https://steemit.com/tutorial/@hardlydifficult/decentraland-tutorial-basic-ai-with-block-dog

Video: https://youtu.be/61ppyctd-88

decentralandcreeps's People

Contributors

hardlydifficult avatar nearnshaw avatar

Stargazers

 avatar Ian Petrarca avatar Tony avatar Juan Cazala avatar

Watchers

James Cloos avatar  avatar  avatar

decentralandcreeps's Issues

Minor issues

Hi @HardlyDifficult ! This repo was forwarded to me by @nearnshaw to take a look at it in order to use it for a tutorial/video. First of all, great job! I really like the approach you took to build this game, I just wanted to give you some feedback around some minor issues that I think can be improved:

  • The name of the ScriptableScene class is still HouseScene (link)

  • The name of the list of enemies/creeps is entities (i.e. getState().entities), I think this name might be a little misleading since entity is a term used to refer to the 3D entities in the scene like <entity>, maybe a name like enemies or creeps or blobs would be more clear? Same goes for the <Entity> component (link)

  • I see this pattern repeated in the code:

// do something
setTimeout(() => {
  // do something else later
}, 1000)

This pattern becomes a little hard to follow when there are many nested timeouts like here, but if you add a helper like this:

const sleep = (ms: number): Promise<void> => new Promise(resolve => setTimeout(resolve, ms))

Then you can use a pattern like this:

// do something
await sleep(100)
// do something else later
await sleep(1000)
// do something else after that

Which is easier to follow, you just have to make sure to make the function you are executing that helper in an async function, like converting this:

this.eventSubscriber.on('event', () => {
  // do something
  setTimeout(() => {
    // do something else
  }, 1000)
})

into this:

this.eventSubscriber.on('event', async () => {
  // do something
  await sleep(1000)
  // do something else
})

notice the async

- this.eventSubscriber.on('event', () => {
+ this.eventSubscriber.on('event', async () => {
  • And finally, just as a suggestion (it's probably out of the scope for this tutorial) I see that the game starts as soon as the server starts, but there's no concept of a "match". If this were to be deployed to decentraland it would be a never ending match (unless the server restarts). It would be great if the game had some event/condition to make it start (ie clicking on a button) and then an "end" condition (time/score/lives/etc) to make it end the game and go back to initial state. Again, that's just a suggestion if you are planning to deploy this to DCL (which I believe you should totally do!) but I don't think is necessary in order to use this as a tutorial/video.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.