Skip to content

lgrachov/ShootModule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Open this page at https://lgrachov.github.io/shootmodule/

Usage

Normal Shoot

namespace SpriteKind {
    export const Cursor = SpriteKind.create()
}
 let enemy: Sprite;
let shootCursor: Sprite;
function shootCursor_render() {
shootCursor = sprites.create(img`
    1 . . . . . . . . . . . . . . 1
    . 1 . . . . . . . . . . . . 1 .
    . . 1 . . . . . . . . . . 1 . .
    . . . 1 . . . . . . . . 1 . . .
    . . . . 1 . . . . . . 1 . . . .
    . . . . . 1 . . . . 1 . . . . .
    . . . . . . 1 1 1 1 . . . . . .
    . . . . . . 1 . . 1 . . . . . .
    . . . . . . 1 . . 1 . . . . . .
    . . . . . . 1 1 1 1 . . . . . .
    . . . . . 1 . . . . 1 . . . . .
    . . . . 1 . . . . . . 1 . . . .
    . . . 1 . . . . . . . . 1 . . .
    . . 1 . . . . . . . . . . 1 . .
    . 1 . . . . . . . . . . . . 1 .
    1 . . . . . . . . . . . . . . 1
`, SpriteKind.Cursor)
controller.moveSprite(shootCursor)
}

function shootCursor_respawn() {
    shootCursor = sprites.create(img`
        1 . . . . . . . . . . . . . . 1
        . 1 . . . . . . . . . . . . 1 .
        . . 1 . . . . . . . . . . 1 . .
        . . . 1 . . . . . . . . 1 . . .
        . . . . 1 . . . . . . 1 . . . .
        . . . . . 1 . . . . 1 . . . . .
        . . . . . . 1 1 1 1 . . . . . .
        . . . . . . 1 . . 1 . . . . . .
        . . . . . . 1 . . 1 . . . . . .
        . . . . . . 1 1 1 1 . . . . . .
        . . . . . 1 . . . . 1 . . . . .
        . . . . 1 . . . . . . 1 . . . .
        . . . 1 . . . . . . . . 1 . . .
        . . 1 . . . . . . . . . . 1 . .
        . 1 . . . . . . . . . . . . 1 .
        1 . . . . . . . . . . . . . . 1
    `, SpriteKind.Cursor)
    controller.moveSprite(shootCursor)
    shootCursor.setPosition(randint(10, 110), 60)
}

function spawnEnemy() {
    enemy = sprites.create(img`
     ........................
     ......ffff..............
     ....fff22fff............
     ...fff2222fff...........
     ..fffeeeeeefff..........
     ..ffe222222eef..........
     ..fe2ffffff2ef..........
     ..ffffeeeeffff..........
     .ffefbf44fbfeff.........
     .fee41fddf14eef.........
     fdfeeddddd4eff..........
     fbffee444edd4e..........
     fbf4f2222edde...........
     fcf.f22cccee............
     .ff.f44cdc4f............
     ....fffddcff............
     .....fddcff.............
     ....cddc................
     ....cdc.................
     ....cc..................
     ........................
     ........................
     ........................
     ........................
 `, SpriteKind.Enemy);
    enemy.setPosition(randint(10, 110), 60);
}

spawnEnemy();

shootCursor_render()

controller.moveSprite(shootCursor)
controller.A.onEvent(ControllerButtonEvent.Pressed, function() {
    if (shootCursor.overlapsWith(enemy)) {
    sprites.destroy(enemy, effects.fire, 10);
    sprites.destroy(shootCursor)
    shootCursor_respawn()
    }
});
normal-shoot.mp4

Rotating Shoot

namespace SpriteKind {
    export const Cursor = SpriteKind.create()
}
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
    if (shootCursor.overlapsWith(enemy)) {
        sprites.destroy(enemy, effects.fire, 10)
        animation.runImageAnimation(
        shootCursor,
        [img`
            1 . . . . . . . . . . . . . . 1 
            . 1 . . . . . . . . . . . . 1 . 
            . . 1 . . . . . . . . . . 1 . . 
            . . . 1 . . . . . . . . 1 . . . 
            . . . . 1 . . . . . . 1 . . . . 
            . . . . . 1 . . . . 1 . . . . . 
            . . . . . . 1 1 1 1 . . . . . . 
            . . . . . . 1 . . 1 . . . . . . 
            . . . . . . 1 . . 1 . . . . . . 
            . . . . . . 1 1 1 1 . . . . . . 
            . . . . . 1 . . . . 1 . . . . . 
            . . . . 1 . . . . . . 1 . . . . 
            . . . 1 . . . . . . . . 1 . . . 
            . . 1 . . . . . . . . . . 1 . . 
            . 1 . . . . . . . . . . . . 1 . 
            1 . . . . . . . . . . . . . . 1 
            `,img`
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . 1 1 1 . . . . . . . 
            1 1 1 1 1 1 1 . 1 1 1 1 1 1 1 1 
            . . . . . . 1 1 1 . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            `,img`
            1 . . . . . . . . . . . . . . 1 
            . 1 . . . . . . . . . . . . 1 . 
            . . 1 . . . . . . . . . . 1 . . 
            . . . 1 . . . . . . . . 1 . . . 
            . . . . 1 . . . . . . 1 . . . . 
            . . . . . 1 . . . . 1 . . . . . 
            . . . . . . 1 1 1 1 . . . . . . 
            . . . . . . 1 . . 1 . . . . . . 
            . . . . . . 1 . . 1 . . . . . . 
            . . . . . . 1 1 1 1 . . . . . . 
            . . . . . 1 . . . . 1 . . . . . 
            . . . . 1 . . . . . . 1 . . . . 
            . . . 1 . . . . . . . . 1 . . . 
            . . 1 . . . . . . . . . . 1 . . 
            . 1 . . . . . . . . . . . . 1 . 
            1 . . . . . . . . . . . . . . 1 
            `,img`
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . 1 1 1 . . . . . . . 
            1 1 1 1 1 1 1 . 1 1 1 1 1 1 1 1 
            . . . . . . 1 1 1 . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            . . . . . . . 1 . . . . . . . . 
            `],
        500,
        false
        )
        pause(2000)
        sprites.destroy(shootCursor)
        shootCursor_respawn()
    }
})
function shootCursor_render () {
    shootCursor = sprites.create(img`
        1 . . . . . . . . . . . . . . 1 
        . 1 . . . . . . . . . . . . 1 . 
        . . 1 . . . . . . . . . . 1 . . 
        . . . 1 . . . . . . . . 1 . . . 
        . . . . 1 . . . . . . 1 . . . . 
        . . . . . 1 . . . . 1 . . . . . 
        . . . . . . 1 1 1 1 . . . . . . 
        . . . . . . 1 . . 1 . . . . . . 
        . . . . . . 1 . . 1 . . . . . . 
        . . . . . . 1 1 1 1 . . . . . . 
        . . . . . 1 . . . . 1 . . . . . 
        . . . . 1 . . . . . . 1 . . . . 
        . . . 1 . . . . . . . . 1 . . . 
        . . 1 . . . . . . . . . . 1 . . 
        . 1 . . . . . . . . . . . . 1 . 
        1 . . . . . . . . . . . . . . 1 
        `, SpriteKind.Cursor)
    controller.moveSprite(shootCursor)
}
function spawnEnemy () {
    enemy = sprites.create(img`
        ........................
        ......ffff..............
        ....fff22fff............
        ...fff2222fff...........
        ..fffeeeeeefff..........
        ..ffe222222eef..........
        ..fe2ffffff2ef..........
        ..ffffeeeeffff..........
        .ffefbf44fbfeff.........
        .fee41fddf14eef.........
        fdfeeddddd4eff..........
        fbffee444edd4e..........
        fbf4f2222edde...........
        fcf.f22cccee............
        .ff.f44cdc4f............
        ....fffddcff............
        .....fddcff.............
        ....cddc................
        ....cdc.................
        ....cc..................
        ........................
        ........................
        ........................
        ........................
        `, SpriteKind.Enemy)
    enemy.setPosition(randint(10, 110), 60)
}
function shootCursor_respawn () {
    shootCursor = sprites.create(img`
        1 . . . . . . . . . . . . . . 1 
        . 1 . . . . . . . . . . . . 1 . 
        . . 1 . . . . . . . . . . 1 . . 
        . . . 1 . . . . . . . . 1 . . . 
        . . . . 1 . . . . . . 1 . . . . 
        . . . . . 1 . . . . 1 . . . . . 
        . . . . . . 1 1 1 1 . . . . . . 
        . . . . . . 1 . . 1 . . . . . . 
        . . . . . . 1 . . 1 . . . . . . 
        . . . . . . 1 1 1 1 . . . . . . 
        . . . . . 1 . . . . 1 . . . . . 
        . . . . 1 . . . . . . 1 . . . . 
        . . . 1 . . . . . . . . 1 . . . 
        . . 1 . . . . . . . . . . 1 . . 
        . 1 . . . . . . . . . . . . 1 . 
        1 . . . . . . . . . . . . . . 1 
        `, SpriteKind.Cursor)
    controller.moveSprite(shootCursor)
    shootCursor.setPosition(randint(10, 110), 60)
}
let enemy: Sprite;
let shootCursor: Sprite;
spawnEnemy()
shootCursor_render()
controller.moveSprite(shootCursor)
rotating-shoot.mp4

Use as Extension

This repository can be added as an extension in MakeCode.

* open https://arcade.makecode.com/ * click on New Project * click on Extensions under the gearwheel menu * search for https://github.com/lgrachov/shootmodule and import

Edit this project Build status badge

To edit this repository in MakeCode.

Blocks preview

This image shows the blocks code from the last commit in master. This image may take a few minutes to refresh.

A rendered view of the blocks

Metadata (used for search, rendering)

  • for PXT/arcade
<script src="https://makecode.com/gh-pages-embed.js"></script><script>makeCodeRender("{{ site.makecode.home_url }}", "{{ site.github.owner_name }}/{{ site.github.repository_name }}");</script>

About

An shoot πŸ”« module for games

Topics

Resources

Stars

Watchers

Forks