Giter Club home page Giter Club logo

fang-die-elfen's Introduction

Fang die Elfen

~avatar avatar @unplugged

Die Elfen sind außer Rand und Band. Sie flitzen wie wild über den Calliope-Bildschirm!
Deine einzige Chance sie einzufangen ist es, wenn sie in der Mitte des Bildschirms sind. Dann kannst du die Taste A drücken, um einen zu fangen.
ElfenFangen

Schritt 1

Erstelle ||basic:beim Start|| eine Variable ||variables:Elfen|| und eine Variable namens ||variables:Zeit|| und stelle eine Zeit von 22 ein.
Hier kannst du auch gleich noch den Block ||game: setze Anzahl Leben|| einfügen.

let zeit = 0
let Elfen= game.createSprite(2, 2)
zeit = 200
game.setLife(10)

Schritt 2

Um die Elfen über den Bildschirm flitzen zu lassen, sollen sie sich zu Beginn des ||basic:dauerhaft|| Blocks ||game: um 1 bewegen||.
Anschließend soll mit einer ||logic:wenn-dann|| - Bedingung geprüft werden, ob der Elf schon den Rand berührt.
Sollte er den Rand berühren, kannst du mithilfe von weiteren ||logic:wenn-dann|| - Bedingungen und einer ||math:zufälligen|| Zahl die Elfen in eine immer wieder andere ||game:Richtung|| abprallen lassen.

Probiere dies am besten erstmal selbst aus, bevor du in die Lösung schaust!

Schritt 3

Ich hoffe, du hast es erstmal selbst versucht. Sollte es noch kleinere Buggs geben, wäre hier auch eine Lösungsmöglichkeit:

input.onButtonPressed(Button.A, function () {
    if (Elfen.get(LedSpriteProperty.X) == 2 && Elfen.get(LedSpriteProperty.Y) == 2) {
        game.addScore(1)
        zeit = Math.max(50, 200 - 5 * game.score())
    } else {
        game.removeLife(1)
    }
})
let zeit = 0
let Elfen = game.createSprite(2, 2)
zeit = 200
game.setLife(10)
basic.forever(function () {
    Elfen.move(1)
    if (Elfen.isTouchingEdge()) {
        if (Elfen.get(LedSpriteProperty.Y) == 2) {
            if (Elfen.get(LedSpriteProperty.X) > 2) {
                Elfen.set(LedSpriteProperty.Direction, randint(-1, -3) * 45)
            } else {
                Elfen.set(LedSpriteProperty.Direction, randint(1, 3) * 45)
            }
        } else {
            if (Elfen.get(LedSpriteProperty.Y) > 2) {
                Elfen.set(LedSpriteProperty.Direction, randint(-1, 1) * 45)
            } else {
                Elfen.set(LedSpriteProperty.Direction, randint(3, 5) * 45)
            }
        }
        basic.pause(100)
        Elfen.move(1)
    }
    basic.pause(zeit)
})

fang-die-elfen's People

Contributors

r00b1nh00d avatar

Watchers

 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.