Giter VIP home page Giter VIP logo

discord.py-game-engine's Introduction

discord.py-game-engine

A game engine for discord


How to use

If you want to see some examples go here or follow almong this tutorial to get a basic understanding of how this module works.

Start by importing the module

import discord_game
from discord_game import screen

You will also need the discord libary to create the client

import discord

Then you can start by creating the discord client

client = discord.Client()

Now you can create the game and set its startcommand. Our is !start

game = discord_game.Game(client, "!start")

Use the onStart event to run code when someone starts the game. The onBotReady runs when the bot/client is ready.

@game.event.onStart
async def onStart(display):
    print("The game is started")

@game.event.onBotReady
async def ready():
    print("bot is ready")

Don't forget to add client.run(token) at the end of the file

client.run("Your token")

You can create a sprite like this

mySprite = screen.Sprite(display, ["costume", "with", "multiple rows"], 0, 0) # and lastly x and y pos

Then you will need to update the display

await display.update()

To create a button you do it like this

myButton = await s.addButton("Click me!")

To get a button click put this code inside the onstart function

@myButton.onClick
async def clicked(btn):
    print("You clicked me!")

The complete code

import discord_game
from discord_game import screen
import discord

client = discord.Client()

game = discord_game.Game(client, "!start")

@game.event.onStart
async def onStart(display):
    print("The game is started")

@game.event.onBotReady
async def ready():
    print("bot is ready")

    mySprite = screen.Sprite(display, ["costume", "with", "multiple rows"], 0, 0) # and lastly x and y pos

    await display.update()

    myButton = await s.addButton("Click me!")

    @myButton.onClick
    async def clicked(btn):
        print("You clicked me!")
    
client.run("Your token")

discord.py-game-engine's People

Contributors

vl07 avatar

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.