├── liveupdate.settings ├── psds ├── auras.psd ├── pearl.psd ├── defold.psd └── defold2.psd ├── examples ├── _render │ ├── default.render │ ├── custom │ │ ├── custom.render │ │ └── custom.render_script │ ├── readme.txt │ ├── default.display_profiles │ └── default.render_script ├── toys │ ├── orbit │ │ ├── crosshairs.png │ │ ├── crosshairs.pyxel │ │ ├── pixel_ships.png │ │ ├── pixel_ships.pyxel │ │ ├── pixel_ships.tilesource │ │ ├── ship.script │ │ ├── orb.go │ │ ├── manager.script │ │ ├── crosshair.script │ │ ├── pixel_ship_freemove.script │ │ └── crosshairs.tilesource │ ├── bouncer │ │ ├── images │ │ │ └── logo.png │ │ ├── logo.atlas │ │ ├── ground_gen.script │ │ ├── ball.script │ │ ├── big_wall.collection │ │ └── ground.collection │ ├── konami_code │ │ ├── sawsquarenoise_-_01_-_Interstellar.ogg │ │ ├── sawsquarenoise_-_01_-_Interstellar_LICENSE.txt │ │ ├── konami_code.script │ │ └── konami_code.collection │ ├── shooter │ │ ├── shooter_tiles.tilesource │ │ ├── mouse_checker.script │ │ ├── shooter_sprites.tilesource │ │ └── tile_manager.script │ ├── identicons │ │ ├── identicons.tilesource │ │ ├── identicon_prefab.go │ │ ├── identicon_manager.script │ │ ├── identicons.tilemap │ │ └── identicons.script │ ├── minesweeper │ │ ├── minesweeper_cells.tilesource │ │ ├── minesweeper_borders.tilesource │ │ ├── minesweeper_numbers.tilemap │ │ ├── minesweeper_character.tilesource │ │ └── minesweeper_numbers.tilesource │ ├── arc_swing │ │ ├── spacer.go │ │ ├── swing.script │ │ └── bouncer_ball.go │ ├── random_level │ │ ├── random_level.collection │ │ └── random_level.script │ └── rpg_movement │ │ └── critters.tilesource ├── effects │ └── spinning_aura │ │ ├── particles.script │ │ └── spinning_aura.script ├── tools │ ├── texture_dynamic_buffer │ │ ├── texture_64_2.png │ │ ├── buffer_sprite_1.atlas │ │ ├── buffer_sprite_2.atlas │ │ ├── texture_64.atlas │ │ └── buffer_controller.script │ ├── curves │ │ ├── dot.go │ │ ├── pearl.go │ │ └── pearl.script │ ├── html_run_code │ │ ├── html_run_code.collection │ │ ├── html_run_code.script │ │ └── index.html │ ├── api_ext │ │ ├── api_ext.script │ │ └── api_ext.collection │ ├── colors │ │ ├── colors.script │ │ └── colors.collection │ ├── easing_equations │ │ ├── easing_equations.script │ │ └── easing_equations.collection │ └── ms_rng │ │ ├── ms_rng.script │ │ └── ms_rng.collection └── input │ ├── multitouch │ ├── particlefx_set_tint_color.script │ ├── multitouch.script │ ├── poof_1.particlefx │ ├── poof_2.particlefx │ ├── poof_3.particlefx │ ├── poof_4.particlefx │ └── poof_5.particlefx │ ├── 4dir_move │ ├── 4dir_move.collection │ └── 4dir_move.script │ ├── text_typing │ ├── text_typing.script │ └── text_typing.collection │ └── alt_f4 │ └── alt_f4.collection ├── pyxels ├── critters.png ├── critters.pyxel ├── critters2.png ├── minesweeper.png ├── minesweeper.pyxel ├── shooter_tiles.png ├── buffer_sprite_1.png ├── buffer_sprite_2.png ├── shooter_sprites.png ├── shooter_tiles.pyxel ├── buffer_sprite_1.pyxel ├── buffer_sprite_2.pyxel ├── pastel_tile_colors.png ├── shooter_sprites.pyxel └── pastel_tile_colors.pyxel ├── defrs ├── utils │ ├── colors.json │ ├── mouse_helper.lua │ ├── api_ext.lua │ ├── format_time.lua │ ├── random.lua │ ├── rng.lua │ ├── deep_copy.lua │ ├── superstrict.lua │ ├── timer.lua │ ├── mini_profiler.lua │ ├── rgb_hex.lua │ ├── uuid.lua │ ├── prettify.lua │ ├── mersennetwister.lua │ ├── perlin.lua │ ├── astar.lua │ ├── types.lua │ ├── stringbuffer.lua │ ├── constants.lua │ ├── all_top_sorts.lua │ ├── vec2d.lua │ └── animations.lua ├── assets │ └── textures │ │ ├── misc │ │ ├── pearl.png │ │ └── misc.atlas │ │ └── auras │ │ ├── aura_blue.png │ │ └── auras.atlas ├── fonts │ ├── nes_chimera │ │ ├── nes_chimera.ttf │ │ ├── nes_chimera_bmfont_0.png │ │ ├── nes_chimera_bmfont_0.psd │ │ ├── nes_chimera.font │ │ └── nes_chimera_bmfont.bmfc │ └── materials │ │ ├── pixel_font_bmfnt.fp │ │ ├── pixel_font.material │ │ ├── pixel_font_bmfnt.material │ │ ├── pixel_font_toptile.material │ │ ├── pixel_font.fp │ │ ├── pixel_font_toptile.fp │ │ ├── pixel_font_bmfnt.vp │ │ ├── pixel_font.vp │ │ └── pixel_font_toptile.vp ├── gui │ ├── screen_size.gui │ └── screen_size.go ├── materials │ ├── sprite_normal.vp │ ├── sprite_pixelart.vp │ ├── sprite_pixelart_buffer.vp │ ├── sprite_normal.fp │ ├── sprite_pixelart.fp │ ├── tile_map_pixelart.fp │ ├── sprite_pixelart_buffer.fp │ ├── tile_map_pixelart.vp │ ├── sprite_normal.material │ ├── sprite_pixelart.material │ ├── sprite_pixelart_buffer.material │ └── tile_map_pixelart.material ├── scripts │ ├── go_set_scale.script │ ├── sprite_set_tint_color.script │ └── handle_alt_f4.script └── toys │ ├── rpg_hp.lua │ └── rpg_xp.lua ├── target_resources ├── html5 │ ├── todo.txt │ └── index.html ├── linux │ └── defold.png ├── macos │ └── defold2.icns ├── windows │ └── defold.ico ├── ios │ ├── iTunesArtwork@1x.png │ ├── iTunesArtwork@2x.png │ ├── iTunesArtwork@3x.png │ └── AppIcon.appiconset │ │ ├── Icon-App-20x20@1x.png │ │ ├── Icon-App-20x20@2x.png │ │ ├── Icon-App-20x20@3x.png │ │ ├── Icon-App-29x29@1x.png │ │ ├── Icon-App-29x29@2x.png │ │ ├── Icon-App-29x29@3x.png │ │ ├── Icon-App-40x40@1x.png │ │ ├── Icon-App-40x40@2x.png │ │ ├── Icon-App-40x40@3x.png │ │ ├── Icon-App-57x57@1x.png │ │ ├── Icon-App-57x57@2x.png │ │ ├── Icon-App-60x60@1x.png │ │ ├── Icon-App-60x60@2x.png │ │ ├── Icon-App-60x60@3x.png │ │ ├── Icon-App-72x72@1x.png │ │ ├── Icon-App-72x72@2x.png │ │ ├── Icon-App-76x76@1x.png │ │ ├── Icon-App-76x76@2x.png │ │ ├── Icon-App-76x76@3x.png │ │ ├── Icon-Small-50x50@1x.png │ │ ├── Icon-Small-50x50@2x.png │ │ └── Icon-App-83.5x83.5@2x.png └── android │ ├── playstore-icon.png │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-ldpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ └── mipmap-xxxhdpi │ └── ic_launcher.png ├── .gitignore ├── game.project ├── input └── game.input_binding └── README.md /liveupdate.settings: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /psds/auras.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/psds/auras.psd -------------------------------------------------------------------------------- /psds/pearl.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/psds/pearl.psd -------------------------------------------------------------------------------- /psds/defold.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/psds/defold.psd -------------------------------------------------------------------------------- /psds/defold2.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/psds/defold2.psd -------------------------------------------------------------------------------- /examples/_render/default.render: -------------------------------------------------------------------------------- 1 | script: "/examples/_render/default.render_script" 2 | -------------------------------------------------------------------------------- /pyxels/critters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/pyxels/critters.png -------------------------------------------------------------------------------- /pyxels/critters.pyxel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/pyxels/critters.pyxel -------------------------------------------------------------------------------- /pyxels/critters2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/pyxels/critters2.png -------------------------------------------------------------------------------- /pyxels/minesweeper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/pyxels/minesweeper.png -------------------------------------------------------------------------------- /defrs/utils/colors.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/defrs/utils/colors.json -------------------------------------------------------------------------------- /examples/_render/custom/custom.render: -------------------------------------------------------------------------------- 1 | script: "/examples/_render/custom/custom.render_script" 2 | -------------------------------------------------------------------------------- /pyxels/minesweeper.pyxel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/pyxels/minesweeper.pyxel -------------------------------------------------------------------------------- /pyxels/shooter_tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/pyxels/shooter_tiles.png -------------------------------------------------------------------------------- /defrs/utils/mouse_helper.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | M.mouse_x = 0.0 4 | M.mouse_y = 0.0 5 | 6 | return M -------------------------------------------------------------------------------- /pyxels/buffer_sprite_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/pyxels/buffer_sprite_1.png -------------------------------------------------------------------------------- /pyxels/buffer_sprite_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/pyxels/buffer_sprite_2.png -------------------------------------------------------------------------------- /pyxels/shooter_sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/pyxels/shooter_sprites.png -------------------------------------------------------------------------------- /pyxels/shooter_tiles.pyxel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/pyxels/shooter_tiles.pyxel -------------------------------------------------------------------------------- /pyxels/buffer_sprite_1.pyxel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/pyxels/buffer_sprite_1.pyxel -------------------------------------------------------------------------------- /pyxels/buffer_sprite_2.pyxel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/pyxels/buffer_sprite_2.pyxel -------------------------------------------------------------------------------- /pyxels/pastel_tile_colors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/pyxels/pastel_tile_colors.png -------------------------------------------------------------------------------- /pyxels/shooter_sprites.pyxel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/pyxels/shooter_sprites.pyxel -------------------------------------------------------------------------------- /target_resources/html5/todo.txt: -------------------------------------------------------------------------------- 1 | - remake with latest generated html 2 | - setup fixed ratio render script -------------------------------------------------------------------------------- /pyxels/pastel_tile_colors.pyxel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/pyxels/pastel_tile_colors.pyxel -------------------------------------------------------------------------------- /examples/toys/orbit/crosshairs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/examples/toys/orbit/crosshairs.png -------------------------------------------------------------------------------- /target_resources/linux/defold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/linux/defold.png -------------------------------------------------------------------------------- /defrs/assets/textures/misc/pearl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/defrs/assets/textures/misc/pearl.png -------------------------------------------------------------------------------- /examples/effects/spinning_aura/particles.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | particlefx.play("#particlefx") 3 | 4 | end 5 | -------------------------------------------------------------------------------- /examples/toys/bouncer/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/examples/toys/bouncer/images/logo.png -------------------------------------------------------------------------------- /examples/toys/orbit/crosshairs.pyxel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/examples/toys/orbit/crosshairs.pyxel -------------------------------------------------------------------------------- /examples/toys/orbit/pixel_ships.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/examples/toys/orbit/pixel_ships.png -------------------------------------------------------------------------------- /examples/toys/orbit/pixel_ships.pyxel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/examples/toys/orbit/pixel_ships.pyxel -------------------------------------------------------------------------------- /target_resources/macos/defold2.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/macos/defold2.icns -------------------------------------------------------------------------------- /target_resources/windows/defold.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/windows/defold.ico -------------------------------------------------------------------------------- /defrs/fonts/nes_chimera/nes_chimera.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/defrs/fonts/nes_chimera/nes_chimera.ttf -------------------------------------------------------------------------------- /defrs/assets/textures/auras/aura_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/defrs/assets/textures/auras/aura_blue.png -------------------------------------------------------------------------------- /target_resources/ios/iTunesArtwork@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/iTunesArtwork@1x.png -------------------------------------------------------------------------------- /target_resources/ios/iTunesArtwork@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/iTunesArtwork@2x.png -------------------------------------------------------------------------------- /target_resources/ios/iTunesArtwork@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/iTunesArtwork@3x.png -------------------------------------------------------------------------------- /target_resources/android/playstore-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/android/playstore-icon.png -------------------------------------------------------------------------------- /defrs/fonts/nes_chimera/nes_chimera_bmfont_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/defrs/fonts/nes_chimera/nes_chimera_bmfont_0.png -------------------------------------------------------------------------------- /defrs/fonts/nes_chimera/nes_chimera_bmfont_0.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/defrs/fonts/nes_chimera/nes_chimera_bmfont_0.psd -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .externalToolBuilders 2 | .DS_Store 3 | .lock-wscript 4 | build 5 | *.pyc 6 | .project 7 | .cproject 8 | builtins 9 | .internal 10 | -------------------------------------------------------------------------------- /target_resources/android/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/android/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /target_resources/android/mipmap-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/android/mipmap-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /target_resources/android/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/android/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/_render/readme.txt: -------------------------------------------------------------------------------- 1 | The only thing this custom render script does is increase the render near/far range from -1 - 1 to -1000 to 1000 for general uses. -------------------------------------------------------------------------------- /examples/tools/texture_dynamic_buffer/texture_64_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/examples/tools/texture_dynamic_buffer/texture_64_2.png -------------------------------------------------------------------------------- /target_resources/android/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/android/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /target_resources/android/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/android/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/toys/bouncer/logo.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/examples/toys/bouncer/images/logo.png" 3 | } 4 | margin: 0 5 | extrude_borders: 0 6 | inner_padding: 0 7 | -------------------------------------------------------------------------------- /target_resources/android/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/android/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /defrs/assets/textures/misc/misc.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/defrs/assets/textures/misc/pearl.png" 3 | } 4 | margin: 0 5 | extrude_borders: 0 6 | inner_padding: 0 7 | -------------------------------------------------------------------------------- /defrs/fonts/nes_chimera/nes_chimera.font: -------------------------------------------------------------------------------- 1 | font: "/defrs/fonts/nes_chimera/nes_chimera.ttf" 2 | material: "/builtins/fonts/font.material" 3 | size: 16 4 | all_chars: true 5 | -------------------------------------------------------------------------------- /examples/toys/bouncer/ground_gen.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | collectionfactory.create("#groundfactory", go.get_position("."), go.get_rotation("."), {}, 2) 3 | end 4 | -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-57x57@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-57x57@1x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-57x57@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-57x57@2x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-60x60@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-60x60@1x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-72x72@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-72x72@1x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-72x72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-72x72@2x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-76x76@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-76x76@3x.png -------------------------------------------------------------------------------- /defrs/assets/textures/auras/auras.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/defrs/assets/textures/auras/aura_blue.png" 3 | } 4 | margin: 0 5 | extrude_borders: 0 6 | inner_padding: 0 7 | -------------------------------------------------------------------------------- /examples/toys/konami_code/sawsquarenoise_-_01_-_Interstellar.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/examples/toys/konami_code/sawsquarenoise_-_01_-_Interstellar.ogg -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-Small-50x50@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-Small-50x50@1x.png -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-Small-50x50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-Small-50x50@2x.png -------------------------------------------------------------------------------- /examples/tools/texture_dynamic_buffer/buffer_sprite_1.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/pyxels/buffer_sprite_1.png" 3 | } 4 | margin: 0 5 | extrude_borders: 0 6 | inner_padding: 0 7 | -------------------------------------------------------------------------------- /examples/tools/texture_dynamic_buffer/buffer_sprite_2.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/pyxels/buffer_sprite_2.png" 3 | } 4 | margin: 0 5 | extrude_borders: 0 6 | inner_padding: 0 7 | -------------------------------------------------------------------------------- /target_resources/ios/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/defrs/HEAD/target_resources/ios/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /examples/tools/texture_dynamic_buffer/texture_64.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/examples/tools/texture_dynamic_buffer/texture_64_2.png" 3 | } 4 | margin: 0 5 | extrude_borders: 0 6 | inner_padding: 0 7 | -------------------------------------------------------------------------------- /defrs/utils/api_ext.lua: -------------------------------------------------------------------------------- 1 | -- Simply require this file 2 | -- require("defrs.utils.api_ext") 3 | 4 | function sprite.play_animation(url, animation) 5 | msg.post(url, "play_animation", {id = hash(animation)}) 6 | end -------------------------------------------------------------------------------- /examples/effects/spinning_aura/spinning_aura.script: -------------------------------------------------------------------------------- 1 | go.property("speed",2.5) 2 | 3 | function init(self) 4 | go.animate(".", "euler.z", go.PLAYBACK_LOOP_FORWARD, 360, go.EASING_LINEAR, go.get("#script", "speed")) 5 | 6 | end 7 | 8 | -------------------------------------------------------------------------------- /defrs/gui/screen_size.gui: -------------------------------------------------------------------------------- 1 | script: "" 2 | background_color { 3 | x: 0.0 4 | y: 0.0 5 | z: 0.0 6 | w: 0.0 7 | } 8 | material: "/builtins/materials/gui.material" 9 | adjust_reference: ADJUST_REFERENCE_LEGACY 10 | max_nodes: 512 11 | -------------------------------------------------------------------------------- /examples/toys/shooter/shooter_tiles.tilesource: -------------------------------------------------------------------------------- 1 | image: "/pyxels/shooter_tiles.png" 2 | tile_width: 32 3 | tile_height: 32 4 | tile_margin: 0 5 | tile_spacing: 0 6 | collision: "" 7 | material_tag: "tile" 8 | extrude_borders: 2 9 | inner_padding: 0 10 | -------------------------------------------------------------------------------- /defrs/gui/screen_size.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "gui" 3 | component: "/defrs/gui/screen_size.gui" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/_render/default.display_profiles: -------------------------------------------------------------------------------- 1 | profiles { 2 | name: "Landscape" 3 | qualifiers { 4 | width: 1280 5 | height: 720 6 | } 7 | } 8 | profiles { 9 | name: "Portrait" 10 | qualifiers { 11 | width: 720 12 | height: 1280 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/toys/konami_code/sawsquarenoise_-_01_-_Interstellar_LICENSE.txt: -------------------------------------------------------------------------------- 1 | URL: http://freemusicarchive.org/music/sawsquarenoise/OverHeated_Alfa_02/Interstellar 2 | Comments: http://freemusicarchive.org/ 3 | Curator: 4 | Copyright: Attribution-NonCommercial-ShareAlike: http://creativecommons.org/licenses/by-nc-sa/4.0/ -------------------------------------------------------------------------------- /defrs/fonts/materials/pixel_font_bmfnt.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | varying lowp vec4 var_face_color; 3 | 4 | uniform lowp vec4 texture_size_recip; 5 | uniform lowp sampler2D texture; 6 | 7 | void main() 8 | { 9 | gl_FragColor = texture2D(texture, var_texcoord0.xy) * var_face_color * var_face_color.a; 10 | } 11 | -------------------------------------------------------------------------------- /examples/input/multitouch/particlefx_set_tint_color.script: -------------------------------------------------------------------------------- 1 | -- only works with first emitter, make custom script if you want more 2 | 3 | go.property("particlefx_tint",vmath.vector4(1.0, 1.0, 1.0, 1.0)) 4 | 5 | function init(self) 6 | particlefx.set_constant("/poof_1#particlefx", "emitter", "tint", vmath.vector4(1, 0, 0, 1)) 7 | 8 | end -------------------------------------------------------------------------------- /defrs/materials/sprite_normal.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | 3 | // positions are in world space 4 | attribute mediump vec4 position; 5 | attribute mediump vec2 texcoord0; 6 | 7 | varying mediump vec2 var_texcoord0; 8 | 9 | void main() 10 | { 11 | gl_Position = view_proj * vec4(position.xyz, 1.0); 12 | var_texcoord0 = texcoord0; 13 | } 14 | -------------------------------------------------------------------------------- /defrs/materials/sprite_pixelart.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | 3 | // positions are in world space 4 | attribute mediump vec4 position; 5 | attribute mediump vec2 texcoord0; 6 | 7 | varying mediump vec2 var_texcoord0; 8 | 9 | void main() 10 | { 11 | gl_Position = view_proj * vec4(position.xyz, 1.0); 12 | var_texcoord0 = texcoord0; 13 | } 14 | -------------------------------------------------------------------------------- /defrs/materials/sprite_pixelart_buffer.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | 3 | // positions are in world space 4 | attribute mediump vec4 position; 5 | attribute mediump vec2 texcoord0; 6 | 7 | varying mediump vec2 var_texcoord0; 8 | 9 | void main() 10 | { 11 | gl_Position = view_proj * vec4(position.xyz, 1.0); 12 | var_texcoord0 = texcoord0; 13 | } 14 | -------------------------------------------------------------------------------- /defrs/scripts/go_set_scale.script: -------------------------------------------------------------------------------- 1 | -- Add this script as a GO with a #sprite component to be able to change that 2 | -- sprite's tint shader constant from the script properties 3 | -- using a sprite other than #sprite requires a custom version of this script 4 | 5 | go.property("scale",vmath.vector3(1.0, 1.0, 1.0)) 6 | 7 | function init(self) 8 | go.set(".", "scale", self.scale) 9 | end -------------------------------------------------------------------------------- /defrs/materials/sprite_normal.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp vec4 tint; 5 | 6 | void main() 7 | { 8 | // Pre-multiply alpha since all runtime textures already are 9 | lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 10 | gl_FragColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy) * tint_pm; 11 | } 12 | -------------------------------------------------------------------------------- /defrs/materials/sprite_pixelart.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp vec4 tint; 5 | 6 | void main() 7 | { 8 | // Pre-multiply alpha since all runtime textures already are 9 | lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 10 | gl_FragColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy) * tint_pm; 11 | } 12 | -------------------------------------------------------------------------------- /defrs/materials/tile_map_pixelart.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp vec4 tint; 5 | 6 | void main() 7 | { 8 | // Pre-multiply alpha since all runtime textures already are 9 | lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 10 | gl_FragColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy) * tint_pm; 11 | } 12 | -------------------------------------------------------------------------------- /defrs/materials/sprite_pixelart_buffer.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp vec4 tint; 5 | 6 | void main() 7 | { 8 | // Pre-multiply alpha since all runtime textures already are 9 | lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 10 | gl_FragColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy) * tint_pm; 11 | } 12 | -------------------------------------------------------------------------------- /defrs/materials/tile_map_pixelart.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | 4 | attribute mediump vec4 position; 5 | attribute mediump vec2 texcoord0; 6 | 7 | varying mediump vec2 var_texcoord0; 8 | 9 | void main() 10 | { 11 | mediump mat4 mvp = view_proj * world; 12 | gl_Position = mvp * vec4(position.xyz, 1.0); 13 | var_texcoord0 = texcoord0; 14 | } 15 | -------------------------------------------------------------------------------- /defrs/scripts/sprite_set_tint_color.script: -------------------------------------------------------------------------------- 1 | -- Add this script as a GO with a #sprite component to be able to change that 2 | -- sprite's tint shader constant from the script properties 3 | -- using a sprite other than #sprite requires a custom version of this script 4 | 5 | go.property("tint",vmath.vector4(1.0, 1.0, 1.0, 1.0)) 6 | 7 | function init(self) 8 | sprite.set_constant("#sprite", "tint", self.tint) 9 | end -------------------------------------------------------------------------------- /examples/toys/identicons/identicons.tilesource: -------------------------------------------------------------------------------- 1 | image: "/pyxels/pastel_tile_colors.png" 2 | tile_width: 32 3 | tile_height: 32 4 | tile_margin: 0 5 | tile_spacing: 0 6 | collision: "" 7 | material_tag: "tile" 8 | animations { 9 | id: "1" 10 | start_tile: 1 11 | end_tile: 1 12 | playback: PLAYBACK_ONCE_FORWARD 13 | fps: 30 14 | flip_horizontal: 0 15 | flip_vertical: 0 16 | } 17 | extrude_borders: 2 18 | inner_padding: 0 19 | -------------------------------------------------------------------------------- /examples/toys/minesweeper/minesweeper_cells.tilesource: -------------------------------------------------------------------------------- 1 | image: "/pyxels/minesweeper.png" 2 | tile_width: 32 3 | tile_height: 32 4 | tile_margin: 0 5 | tile_spacing: 0 6 | collision: "" 7 | material_tag: "tile" 8 | animations { 9 | id: "blank" 10 | start_tile: 1 11 | end_tile: 1 12 | playback: PLAYBACK_ONCE_FORWARD 13 | fps: 30 14 | flip_horizontal: 0 15 | flip_vertical: 0 16 | } 17 | extrude_borders: 2 18 | inner_padding: 0 19 | -------------------------------------------------------------------------------- /examples/toys/orbit/pixel_ships.tilesource: -------------------------------------------------------------------------------- 1 | image: "/examples/toys/orbit/pixel_ships.png" 2 | tile_width: 32 3 | tile_height: 32 4 | tile_margin: 0 5 | tile_spacing: 0 6 | collision: "" 7 | material_tag: "tile" 8 | animations { 9 | id: "anim" 10 | start_tile: 4 11 | end_tile: 4 12 | playback: PLAYBACK_ONCE_FORWARD 13 | fps: 30 14 | flip_horizontal: 0 15 | flip_vertical: 0 16 | } 17 | extrude_borders: 2 18 | inner_padding: 0 19 | -------------------------------------------------------------------------------- /examples/toys/minesweeper/minesweeper_borders.tilesource: -------------------------------------------------------------------------------- 1 | image: "/pyxels/minesweeper.png" 2 | tile_width: 16 3 | tile_height: 16 4 | tile_margin: 0 5 | tile_spacing: 0 6 | collision: "" 7 | material_tag: "tile" 8 | collision_groups: "default" 9 | animations { 10 | id: "anim" 11 | start_tile: 1 12 | end_tile: 1 13 | playback: PLAYBACK_ONCE_FORWARD 14 | fps: 30 15 | flip_horizontal: 0 16 | flip_vertical: 0 17 | } 18 | extrude_borders: 2 19 | inner_padding: 0 20 | -------------------------------------------------------------------------------- /defrs/fonts/materials/pixel_font.material: -------------------------------------------------------------------------------- 1 | name: "pixel_font" 2 | tags: "tile" 3 | vertex_program: "/defrs/fonts/materials/pixel_font.vp" 4 | fragment_program: "/defrs/fonts/materials/pixel_font.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | samplers { 10 | name: "texture" 11 | wrap_u: WRAP_MODE_REPEAT 12 | wrap_v: WRAP_MODE_REPEAT 13 | filter_min: FILTER_MODE_MIN_NEAREST 14 | filter_mag: FILTER_MODE_MAG_NEAREST 15 | } 16 | -------------------------------------------------------------------------------- /examples/tools/curves/dot.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "sprite" 3 | type: "sprite" 4 | data: "tile_set: \"/examples/toys/identicons/identicons.tilesource\"\n" 5 | "default_animation: \"1\"\n" 6 | "material: \"/defrs/materials/sprite_pixelart.material\"\n" 7 | "blend_mode: BLEND_MODE_ALPHA\n" 8 | "" 9 | position { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | } 14 | rotation { 15 | x: 0.0 16 | y: 0.0 17 | z: 0.0 18 | w: 1.0 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /defrs/fonts/materials/pixel_font_bmfnt.material: -------------------------------------------------------------------------------- 1 | name: "font" 2 | tags: "gui" 3 | vertex_program: "/defrs/fonts/materials/pixel_font_bmfnt.vp" 4 | fragment_program: "/defrs/fonts/materials/pixel_font_bmfnt.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | samplers { 10 | name: "texture" 11 | wrap_u: WRAP_MODE_REPEAT 12 | wrap_v: WRAP_MODE_REPEAT 13 | filter_min: FILTER_MODE_MIN_NEAREST 14 | filter_mag: FILTER_MODE_MAG_NEAREST 15 | } 16 | -------------------------------------------------------------------------------- /defrs/fonts/materials/pixel_font_toptile.material: -------------------------------------------------------------------------------- 1 | name: "pixel_font" 2 | tags: "toptile" 3 | vertex_program: "/defrs/fonts/materials/pixel_font_toptile.vp" 4 | fragment_program: "/defrs/fonts/materials/pixel_font_toptile.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | samplers { 10 | name: "texture" 11 | wrap_u: WRAP_MODE_REPEAT 12 | wrap_v: WRAP_MODE_REPEAT 13 | filter_min: FILTER_MODE_MIN_NEAREST 14 | filter_mag: FILTER_MODE_MAG_NEAREST 15 | } 16 | -------------------------------------------------------------------------------- /defrs/fonts/materials/pixel_font.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | varying lowp vec4 var_face_color; 3 | varying lowp vec4 var_outline_color; 4 | varying lowp vec4 var_shadow_color; 5 | 6 | uniform lowp vec4 texture_size_recip; 7 | uniform lowp sampler2D texture; 8 | 9 | void main() 10 | { 11 | // Outline 12 | lowp vec2 t = texture2D(texture, var_texcoord0.xy).xy; 13 | gl_FragColor = vec4(var_face_color.xyz, 1.0) * t.x * var_face_color.w + vec4(var_outline_color.xyz * t.y * var_outline_color.w, t.y * var_outline_color.w) * (1.0 - t.x); 14 | } 15 | -------------------------------------------------------------------------------- /defrs/fonts/materials/pixel_font_toptile.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | varying lowp vec4 var_face_color; 3 | varying lowp vec4 var_outline_color; 4 | varying lowp vec4 var_shadow_color; 5 | 6 | uniform lowp vec4 texture_size_recip; 7 | uniform lowp sampler2D texture; 8 | 9 | void main() 10 | { 11 | // Outline 12 | lowp vec2 t = texture2D(texture, var_texcoord0.xy).xy; 13 | gl_FragColor = vec4(var_face_color.xyz, 1.0) * t.x * var_face_color.w + vec4(var_outline_color.xyz * t.y * var_outline_color.w, t.y * var_outline_color.w) * (1.0 - t.x); 14 | } 15 | -------------------------------------------------------------------------------- /examples/toys/identicons/identicon_prefab.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "script" 3 | component: "/examples/toys/identicons/identicons.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | components { 17 | id: "tilemap" 18 | component: "/examples/toys/identicons/identicons.tilemap" 19 | position { 20 | x: 0.0 21 | y: 0.0 22 | z: 0.0 23 | } 24 | rotation { 25 | x: 0.0 26 | y: 0.0 27 | z: 0.0 28 | w: 1.0 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /examples/toys/minesweeper/minesweeper_numbers.tilemap: -------------------------------------------------------------------------------- 1 | tile_set: "/examples/toys/minesweeper/minesweeper_numbers.tilesource" 2 | layers { 3 | id: "layer1" 4 | z: 0.0 5 | is_visible: 1 6 | cell { 7 | x: 0 8 | y: 0 9 | tile: 20 10 | h_flip: 0 11 | v_flip: 0 12 | } 13 | cell { 14 | x: 1 15 | y: 0 16 | tile: 20 17 | h_flip: 0 18 | v_flip: 0 19 | } 20 | cell { 21 | x: 2 22 | y: 0 23 | tile: 20 24 | h_flip: 0 25 | v_flip: 0 26 | } 27 | } 28 | material: "/defrs/materials/tile_map_pixelart.material" 29 | blend_mode: BLEND_MODE_ALPHA 30 | -------------------------------------------------------------------------------- /defrs/utils/format_time.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.seconds_to_string(seconds) 4 | 5 | if seconds < 60 * 60 then -- MM:SS 6 | return string.format("%02d:%02d", math.floor(seconds / 60), seconds % 60 ) 7 | elseif seconds < 60 * 60 * 24 then -- HH:MM:SS 8 | return string.format("%02d:%02d:%02d", math.floor(seconds / 3600), math.floor(seconds / 60) % 60, seconds % 60) 9 | else -- DD:HH:MM:SS 10 | return string.format("%02d:%02d:%02d:%02d", math.floor(seconds / (3600 * 24)), math.floor(seconds / 3600) % 24, math.floor(seconds / 60) % 60, seconds % 60) 11 | end 12 | 13 | end 14 | 15 | return M -------------------------------------------------------------------------------- /defrs/fonts/materials/pixel_font_bmfnt.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | 3 | varying mediump vec2 var_texcoord0; 4 | varying lowp vec4 var_face_color; 5 | varying lowp vec4 var_outline_color; 6 | 7 | // positions are in world space 8 | attribute mediump vec4 position; 9 | attribute mediump vec2 texcoord0; 10 | attribute lowp vec4 face_color; 11 | attribute lowp vec4 outline_color; 12 | attribute lowp vec4 shadow_color; 13 | 14 | void main() 15 | { 16 | var_texcoord0 = texcoord0; 17 | var_face_color = face_color; 18 | gl_Position = view_proj * vec4(position.x, position.y, position.z, 1.0); 19 | } 20 | -------------------------------------------------------------------------------- /defrs/utils/random.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | -- Improve seeding on OSX and FreeBSD by throwing away the high part of time, 4 | -- then reversing the digits so the least significant part makes the biggest 5 | -- change. 6 | math.randomseed(tonumber(tostring(os.time()):reverse():sub(1,6))) 7 | 8 | function M.boolean() 9 | return math.random(0, 1) == 1 10 | end 11 | 12 | function M.angle(range) 13 | return (math.random() * range * 2) - range 14 | end 15 | 16 | function M.direction(direction, range) 17 | local angle = M.angle(range) 18 | return vmath.rotate(vmath.quat_rotation_z(angle), direction) 19 | end 20 | 21 | return M 22 | -------------------------------------------------------------------------------- /defrs/fonts/materials/pixel_font.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | 3 | varying mediump vec2 var_texcoord0; 4 | varying lowp vec4 var_face_color; 5 | varying lowp vec4 var_outline_color; 6 | 7 | // positions are in world space 8 | attribute mediump vec4 position; 9 | attribute mediump vec2 texcoord0; 10 | attribute lowp vec4 face_color; 11 | attribute lowp vec4 outline_color; 12 | attribute lowp vec4 shadow_color; 13 | 14 | void main() 15 | { 16 | var_texcoord0 = texcoord0; 17 | var_face_color = face_color; 18 | var_outline_color = outline_color; 19 | gl_Position = view_proj * vec4(position.x, position.y, position.z, 1.0); 20 | } 21 | -------------------------------------------------------------------------------- /defrs/materials/sprite_normal.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | vertex_program: "/defrs/materials/sprite_normal.vp" 4 | fragment_program: "/defrs/materials/sprite_normal.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | fragment_constants { 10 | name: "tint" 11 | type: CONSTANT_TYPE_USER 12 | value { 13 | x: 1.0 14 | y: 1.0 15 | z: 1.0 16 | w: 1.0 17 | } 18 | } 19 | samplers { 20 | name: "DIFFUSE_TEXTURE" 21 | wrap_u: WRAP_MODE_REPEAT 22 | wrap_v: WRAP_MODE_REPEAT 23 | filter_min: FILTER_MODE_MIN_LINEAR_MIPMAP_LINEAR 24 | filter_mag: FILTER_MODE_MAG_LINEAR 25 | } 26 | -------------------------------------------------------------------------------- /defrs/fonts/materials/pixel_font_toptile.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | 3 | varying mediump vec2 var_texcoord0; 4 | varying lowp vec4 var_face_color; 5 | varying lowp vec4 var_outline_color; 6 | 7 | // positions are in world space 8 | attribute mediump vec4 position; 9 | attribute mediump vec2 texcoord0; 10 | attribute lowp vec4 face_color; 11 | attribute lowp vec4 outline_color; 12 | attribute lowp vec4 shadow_color; 13 | 14 | void main() 15 | { 16 | var_texcoord0 = texcoord0; 17 | var_face_color = face_color; 18 | var_outline_color = outline_color; 19 | gl_Position = view_proj * vec4(position.x, position.y, position.z, 1.0); 20 | } 21 | -------------------------------------------------------------------------------- /defrs/materials/sprite_pixelart.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | vertex_program: "/defrs/materials/sprite_pixelart.vp" 4 | fragment_program: "/defrs/materials/sprite_pixelart.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | fragment_constants { 10 | name: "tint" 11 | type: CONSTANT_TYPE_USER 12 | value { 13 | x: 1.0 14 | y: 1.0 15 | z: 1.0 16 | w: 1.0 17 | } 18 | } 19 | samplers { 20 | name: "DIFFUSE_TEXTURE" 21 | wrap_u: WRAP_MODE_REPEAT 22 | wrap_v: WRAP_MODE_REPEAT 23 | filter_min: FILTER_MODE_MIN_LINEAR_MIPMAP_NEAREST 24 | filter_mag: FILTER_MODE_MAG_NEAREST 25 | } 26 | -------------------------------------------------------------------------------- /defrs/materials/sprite_pixelart_buffer.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | vertex_program: "/defrs/materials/sprite_pixelart_buffer.vp" 4 | fragment_program: "/defrs/materials/sprite_pixelart_buffer.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | fragment_constants { 10 | name: "tint" 11 | type: CONSTANT_TYPE_USER 12 | value { 13 | x: 1.0 14 | y: 1.0 15 | z: 1.0 16 | w: 1.0 17 | } 18 | } 19 | samplers { 20 | name: "DIFFUSE_TEXTURE" 21 | wrap_u: WRAP_MODE_REPEAT 22 | wrap_v: WRAP_MODE_REPEAT 23 | filter_min: FILTER_MODE_MIN_NEAREST 24 | filter_mag: FILTER_MODE_MAG_NEAREST 25 | } 26 | -------------------------------------------------------------------------------- /examples/toys/identicons/identicon_manager.script: -------------------------------------------------------------------------------- 1 | local objects = {} 2 | 3 | function create_objects() 4 | local total = 0 5 | local padding = 25 6 | for i = 1, 3, 1 do 7 | for j = 1, 3, 1 do 8 | total = total + 1 9 | objects[total] = factory.create("#factory", vmath.vector3(0.0 + (160+padding) * i +350, 0.0 + (160+padding) * j, 0.0)) 10 | end 11 | end 12 | end 13 | 14 | function on_input(self, action_id, action) 15 | if action_id == hash("touch") and action.pressed then 16 | for key, value in ipairs(objects) do 17 | msg.post(value,"randomize_tiles") 18 | end 19 | end 20 | end 21 | 22 | function init(self) 23 | msg.post(".", "acquire_input_focus") 24 | create_objects() 25 | end -------------------------------------------------------------------------------- /defrs/utils/rng.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | -- Require this once to setup your math.rng so that it's random based on OS time 4 | -- you do not need to call M.setup_rng() yourself and generally shouldn't 5 | 6 | 7 | 8 | function M.setup_rng() 9 | math.randomseed(os.time() + math.random()) 10 | math.random(); math.random(); math.random() -- clear bad rng 11 | end 12 | 13 | function M.random(first, second) 14 | if first == nil then 15 | return math.random() 16 | elseif second == nil then 17 | return math.random(first) 18 | else 19 | return math.random(first, second) 20 | end 21 | end 22 | 23 | function M.randomseed(seed) 24 | math.randomseed(seed) 25 | end 26 | 27 | M.setup_rng() 28 | 29 | return M -------------------------------------------------------------------------------- /defrs/materials/tile_map_pixelart.material: -------------------------------------------------------------------------------- 1 | name: "tile_map" 2 | tags: "tile" 3 | vertex_program: "/defrs/materials/tile_map_pixelart.vp" 4 | fragment_program: "/defrs/materials/tile_map_pixelart.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "world" 11 | type: CONSTANT_TYPE_WORLD 12 | } 13 | fragment_constants { 14 | name: "tint" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 1.0 18 | y: 1.0 19 | z: 1.0 20 | w: 1.0 21 | } 22 | } 23 | samplers { 24 | name: "DIFFUSE_TEXTURE" 25 | wrap_u: WRAP_MODE_REPEAT 26 | wrap_v: WRAP_MODE_REPEAT 27 | filter_min: FILTER_MODE_MIN_NEAREST 28 | filter_mag: FILTER_MODE_MAG_NEAREST 29 | } 30 | -------------------------------------------------------------------------------- /examples/tools/curves/pearl.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "script" 3 | component: "/examples/tools/curves/pearl.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | embedded_components { 17 | id: "sprite" 18 | type: "sprite" 19 | data: "tile_set: \"/defrs/assets/textures/misc/misc.atlas\"\n" 20 | "default_animation: \"pearl\"\n" 21 | "material: \"/defrs/materials/sprite_normal.material\"\n" 22 | "blend_mode: BLEND_MODE_ALPHA\n" 23 | "" 24 | position { 25 | x: 0.0 26 | y: 0.0 27 | z: 0.0 28 | } 29 | rotation { 30 | x: 0.0 31 | y: 0.0 32 | z: 0.0 33 | w: 1.0 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/tools/html_run_code/html_run_code.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "components {\n" 6 | " id: \"script\"\n" 7 | " component: \"/examples/tools/html_run_code/html_run_code.script\"\n" 8 | " position {\n" 9 | " x: 0.0\n" 10 | " y: 0.0\n" 11 | " z: 0.0\n" 12 | " }\n" 13 | " rotation {\n" 14 | " x: 0.0\n" 15 | " y: 0.0\n" 16 | " z: 0.0\n" 17 | " w: 1.0\n" 18 | " }\n" 19 | "}\n" 20 | "" 21 | position { 22 | x: 0.0 23 | y: 0.0 24 | z: 0.0 25 | } 26 | rotation { 27 | x: 0.0 28 | y: 0.0 29 | z: 0.0 30 | w: 1.0 31 | } 32 | scale3 { 33 | x: 1.0 34 | y: 1.0 35 | z: 1.0 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /defrs/utils/deep_copy.lua: -------------------------------------------------------------------------------- 1 | --- Makes a proper copy of a table 2 | -- supports meta tables and recursive structures 3 | -- why: normally variables do not hold table values but table references 4 | -- may require modification for your needs, see refs 5 | -- http://www.lua.org/pil/2.5.html 6 | -- http://lua-users.org/wiki/CopyTable 7 | -- http://stackoverflow.com/questions/640642/how-do-you-copy-a-lua-table-by-value 8 | 9 | local M = {} 10 | 11 | function M.deep_copy(obj, seen) 12 | if type(obj) ~= 'table' then return obj end 13 | if seen and seen[obj] then return seen[obj] end 14 | local s = seen or {} 15 | local res = setmetatable({}, getmetatable(obj)) 16 | s[obj] = res 17 | for k, v in pairs(obj) do res[copy3(k, s)] = copy3(v, s) end 18 | return res 19 | end 20 | 21 | return M 22 | -------------------------------------------------------------------------------- /examples/toys/orbit/ship.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | -- Add initialization code here 3 | -- Remove this function if not needed 4 | end 5 | 6 | function final(self) 7 | -- Add finalization code here 8 | -- Remove this function if not needed 9 | end 10 | 11 | function update(self, dt) 12 | -- Add update code here 13 | -- Remove this function if not needed 14 | end 15 | 16 | function on_message(self, message_id, message, sender) 17 | -- Add message-handling code here 18 | -- Remove this function if not needed 19 | end 20 | 21 | function on_input(self, action_id, action) 22 | -- Add input-handling code here 23 | -- Remove this function if not needed 24 | end 25 | 26 | function on_reload(self) 27 | -- Add reload-handling code here 28 | -- Remove this function if not needed 29 | end 30 | -------------------------------------------------------------------------------- /examples/toys/shooter/mouse_checker.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | -- Add initialization code here 3 | -- Remove this function if not needed 4 | end 5 | 6 | function final(self) 7 | -- Add finalization code here 8 | -- Remove this function if not needed 9 | end 10 | 11 | function update(self, dt) 12 | -- Add update code here 13 | -- Remove this function if not needed 14 | end 15 | 16 | function on_message(self, message_id, message, sender) 17 | -- Add message-handling code here 18 | -- Remove this function if not needed 19 | end 20 | 21 | function on_input(self, action_id, action) 22 | -- Add input-handling code here 23 | -- Remove this function if not needed 24 | end 25 | 26 | function on_reload(self) 27 | -- Add reload-handling code here 28 | -- Remove this function if not needed 29 | end 30 | -------------------------------------------------------------------------------- /defrs/toys/rpg_hp.lua: -------------------------------------------------------------------------------- 1 | --- apply damage randomly 2 | -- use something like Mersenne Twister for good random numbers! 3 | health = health or 100 -- total health 4 | attack = attack or {min = 0, max = 10} -- range of possible attack 5 | attack_damage = attack_damage or 0 -- init 6 | total_attacks = total_attacks or 0 -- counter 7 | _ = math.random(attack.min, attack.max) -- dispose of bad RNG 8 | -- comment out the above and see what happens! 9 | -- math.randomseed(os.time()) -- only uncomment after testing above 10 | while health >= 1 do 11 | print("Current HP: " .. health) 12 | attack_damage = math.random(attack.min, attack.max) 13 | health = health - attack_damage 14 | total_attacks = total_attacks + 1 15 | print("Attack #: " .. total_attacks) 16 | if health <= 0 then 17 | print("Dead!") 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /examples/tools/api_ext/api_ext.script: -------------------------------------------------------------------------------- 1 | local sprite_ext = require("defrs.utils.api_ext") 2 | 3 | function init(self) 4 | sprite.play_animation("#sprite", "character_zombie") 5 | end 6 | 7 | function final(self) 8 | -- Add finalization code here 9 | -- Remove this function if not needed 10 | end 11 | 12 | function update(self, dt) 13 | -- Add update code here 14 | -- Remove this function if not needed 15 | end 16 | 17 | function on_message(self, message_id, message, sender) 18 | -- Add message-handling code here 19 | -- Remove this function if not needed 20 | end 21 | 22 | function on_input(self, action_id, action) 23 | -- Add input-handling code here 24 | -- Remove this function if not needed 25 | end 26 | 27 | function on_reload(self) 28 | -- Add reload-handling code here 29 | -- Remove this function if not needed 30 | end 31 | -------------------------------------------------------------------------------- /defrs/utils/superstrict.lua: -------------------------------------------------------------------------------- 1 | -- Protect error function from modification. 2 | local _error = error 3 | 4 | local M = {} 5 | 6 | local function lock_newindex(t, n) 7 | _error("attempting to write value to '" .. n .. "' in locked table [" .. tostring(t) .. "]", 2) 8 | end 9 | 10 | local function lock_index(t, n) 11 | _error("attempting to read undefined value '" .. n .. "' in locked table [" .. tostring(t) .. "]", 2) 12 | end 13 | 14 | function M.lock(t) 15 | assert(t, "missing table to lock") 16 | local mt = getmetatable(t) or {} 17 | mt.__newindex = lock_newindex 18 | mt.__index = lock_index 19 | setmetatable(t, mt) 20 | end 21 | 22 | function M.unlock(t) 23 | assert(t, "missing table to unlock") 24 | local mt = getmetatable(t) or {} 25 | mt.__newindex = rawset 26 | mt.__index = rawget 27 | setmetatable(t, mt) 28 | end 29 | 30 | return M -------------------------------------------------------------------------------- /examples/toys/arc_swing/spacer.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "script" 3 | component: "/defrs/scripts/go_set_scale.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | properties { 16 | id: "scale" 17 | value: "0.125,0.125,1.0" 18 | type: PROPERTY_TYPE_VECTOR3 19 | } 20 | } 21 | embedded_components { 22 | id: "sprite" 23 | type: "sprite" 24 | data: "tile_set: \"/defrs/assets/textures/misc/misc.atlas\"\n" 25 | "default_animation: \"pearl\"\n" 26 | "material: \"/builtins/materials/sprite.material\"\n" 27 | "blend_mode: BLEND_MODE_ALPHA\n" 28 | "" 29 | position { 30 | x: 0.0 31 | y: 0.0 32 | z: 0.0 33 | } 34 | rotation { 35 | x: 0.0 36 | y: 0.0 37 | z: 0.0 38 | w: 1.0 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/toys/orbit/orb.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "script" 3 | component: "/defrs/scripts/sprite_set_tint_color.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | properties { 16 | id: "tint" 17 | value: "1.0,0.921,0.47,1.0" 18 | type: PROPERTY_TYPE_VECTOR4 19 | } 20 | } 21 | embedded_components { 22 | id: "sprite" 23 | type: "sprite" 24 | data: "tile_set: \"/builtins/graphics/particle_blob.tilesource\"\n" 25 | "default_animation: \"anim\"\n" 26 | "material: \"/defrs/materials/sprite_normal.material\"\n" 27 | "blend_mode: BLEND_MODE_ALPHA\n" 28 | "" 29 | position { 30 | x: 0.0 31 | y: 0.0 32 | z: 0.0 33 | } 34 | rotation { 35 | x: 0.0 36 | y: 0.0 37 | z: 0.0 38 | w: 1.0 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/tools/html_run_code/html_run_code.script: -------------------------------------------------------------------------------- 1 | 2 | 3 | function init(self) 4 | sysinfo = sys.get_sys_info() 5 | if sysinfo.system_name == "HTML5" then 6 | html5.run("alert_this('Hello! I am an alert box!!');") 7 | end 8 | end 9 | 10 | function final(self) 11 | -- Add finalization code here 12 | -- Remove this function if not needed 13 | end 14 | 15 | function update(self, dt) 16 | -- Add update code here 17 | -- Remove this function if not needed 18 | end 19 | 20 | function on_message(self, message_id, message, sender) 21 | -- Add message-handling code here 22 | -- Remove this function if not needed 23 | end 24 | 25 | function on_input(self, action_id, action) 26 | -- Add input-handling code here 27 | -- Remove this function if not needed 28 | end 29 | 30 | function on_reload(self) 31 | -- Add reload-handling code here 32 | -- Remove this function if not needed 33 | end 34 | -------------------------------------------------------------------------------- /defrs/utils/timer.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local timers = {} 4 | 5 | function M.frames(frames, callback) 6 | if frames == 0 then 7 | callback() 8 | else 9 | table.insert(timers, {frames = frames, callback = callback}) 10 | end 11 | end 12 | 13 | function M.seconds(seconds, callback) 14 | table.insert(timers, {seconds = seconds, callback = callback}) 15 | end 16 | 17 | function M.cancel_all() 18 | timers = {} 19 | end 20 | 21 | function M.update(dt) 22 | for k, timer in pairs(timers) do 23 | if timer.frames then 24 | timer.frames = timer.frames - 1 25 | if timer.frames <= 0 then 26 | timers[k] = nil 27 | timer.callback() 28 | end 29 | elseif timer.seconds then 30 | timer.seconds = timer.seconds - dt 31 | if timer.seconds <= 0 then 32 | timers[k] = nil 33 | timer.callback() 34 | end 35 | end 36 | end 37 | end 38 | 39 | return M 40 | -------------------------------------------------------------------------------- /examples/tools/colors/colors.script: -------------------------------------------------------------------------------- 1 | local colors = require("defrs.utils.colors") 2 | 3 | 4 | 5 | function init(self) 6 | pprint(colors.red) 7 | pprint(colors.get_random_color()) 8 | pprint(colors.hue_shift(colors.red,1)) 9 | 10 | self.timer = 0 11 | self.step = 1 12 | self.second_color = colors.blue 13 | 14 | end 15 | 16 | function update(self, dt) 17 | self.timer = self.timer + dt 18 | if self.timer > 1 then 19 | self.timer = self.timer - 1 20 | self.step = self.step + 1 21 | if self.step == 4 then 22 | self.step = 1 23 | end 24 | end 25 | if self.step == 1 then 26 | go.set("#label","color",colors.red) 27 | elseif self.step == 2 then 28 | go.set("#label","color",colors.magenta) 29 | elseif self.step == 3 then 30 | go.set("#label","color",colors.get_random_color()) 31 | end 32 | 33 | 34 | go.set("#label2","color",colors.hue_shift(self.second_color,math.cos(self.timer*10))) 35 | go.set("#label3","color",colors.hue_shift(self.second_color,self.timer*30)) 36 | end 37 | -------------------------------------------------------------------------------- /examples/toys/bouncer/ball.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | msg.post(".", "acquire_input_focus") 3 | end 4 | 5 | function on_message(self, message_id, message, sender) 6 | if message_id == hash("ray_cast_response") then 7 | print("Pew!") 8 | end 9 | end 10 | 11 | function on_input(self, action_id, action) 12 | 13 | if action_id == hash("touch") then 14 | local click_location = vmath.vector3(action.screen_x, action.screen_y, 0) 15 | local ray_cast_groups = {hash("default")} 16 | local direction = vmath.vector3((click_location.x - go.get_position(".").x) * 1000,(click_location.y - go.get_position(".").y) * 1000,0 ) 17 | physics.ray_cast(go.get_position("."), click_location, ray_cast_groups, 0) 18 | msg.post("@render:", "draw_line", { start_point = go.get_position("."), end_point = click_location, color = vmath.vector4(1, 1, 1, 1) } ) 19 | msg.post("#collisionobject", "apply_force", { force = direction, position = click_location }) 20 | end 21 | 22 | end 23 | -------------------------------------------------------------------------------- /game.project: -------------------------------------------------------------------------------- 1 | [project] 2 | title = DefRS 3 | version = 1.0 4 | dependencies = https://github.com/britzl/defcon/archive/master.zip, https://github.com/britzl/defnet/archive/3.1.zip 5 | custom_resources = text 6 | 7 | [input] 8 | game_binding = /input/game.input_bindingc 9 | 10 | [bootstrap] 11 | main_collection = /examples/input/4dir_move/4dir_move.collectionc 12 | render = /builtins/render/default.renderc 13 | 14 | [display] 15 | width = 1600 16 | height = 800 17 | samples = 0 18 | 19 | [physics] 20 | scale = 0.02 21 | debug = 0 22 | gravity_y = -1000.0 23 | 24 | [script] 25 | shared_state = 1 26 | 27 | [library] 28 | include_dirs = defrs 29 | 30 | [android] 31 | package = com.subsoap.deffx 32 | 33 | [ios] 34 | bundle_identifier = com.subsoap.deffx 35 | 36 | [osx] 37 | bundle_identifier = com.subsoap.deffx 38 | 39 | [windows] 40 | app_icon = /target_resources/windows/defold.ico 41 | 42 | [particle_fx] 43 | max_count = 256 44 | 45 | [html5] 46 | htmlfile = /examples/tools/html_run_code/index.html 47 | 48 | -------------------------------------------------------------------------------- /examples/tools/curves/pearl.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | -- Add initialization code here 3 | -- Remove this function if not needed 4 | go.animate(".", "scale.x",go.PLAYBACK_LOOP_PINGPONG,go.get(".","scale.x") * 0.25,go.EASING_INOUTBACK,2) 5 | go.animate(".", "scale.y",go.PLAYBACK_LOOP_PINGPONG,go.get(".","scale.y") * 0.25,go.EASING_INOUTBACK,2) 6 | end 7 | 8 | function final(self) 9 | -- Add finalization code here 10 | -- Remove this function if not needed 11 | end 12 | 13 | function update(self, dt) 14 | -- Add update code here 15 | -- Remove this function if not needed 16 | end 17 | 18 | function on_message(self, message_id, message, sender) 19 | -- Add message-handling code here 20 | -- Remove this function if not needed 21 | end 22 | 23 | function on_input(self, action_id, action) 24 | -- Add input-handling code here 25 | -- Remove this function if not needed 26 | end 27 | 28 | function on_reload(self) 29 | -- Add reload-handling code here 30 | -- Remove this function if not needed 31 | end 32 | -------------------------------------------------------------------------------- /defrs/utils/mini_profiler.lua: -------------------------------------------------------------------------------- 1 | --- measure the speed of a section of Lua code 2 | -- call mark1, mark2, and mark3 in order. The intended use case is to either 3 | -- isolate a bottleneck - decided between the first or second interval measured 4 | -- or to get an absolute measure of the average run time of the code 5 | -- between mark1 and mark3. 6 | -- public domain 7 | 8 | local t_sum = 0 9 | local t_num = 0 10 | local t1, t2, t3 11 | local do_time = true 12 | 13 | local function mark1() 14 | if not do_time then return end 15 | t1 = os.clock() 16 | end 17 | 18 | local function mark2() 19 | if not do_time then return end 20 | t2 = os.clock() 21 | end 22 | 23 | local function mark3() 24 | if not do_time then return end 25 | t3 = os.clock() 26 | 27 | print('---') 28 | print(string.format('t1-t3 took %gs', t3 - t1)) 29 | print(string.format('t1-t2 took %gs', t2 - t1)) 30 | print(string.format('t2-t3 took %gs', t3 - t2)) 31 | 32 | t_sum = t_sum + t3 - t1 33 | t_num = t_num + 1 34 | print(string.format('avg t1-t3 is now %gs', t_sum / t_num)) 35 | end 36 | -------------------------------------------------------------------------------- /defrs/fonts/nes_chimera/nes_chimera_bmfont.bmfc: -------------------------------------------------------------------------------- 1 | # AngelCode Bitmap Font Generator configuration file 2 | fileVersion=1 3 | 4 | # font settings 5 | fontName=NES Chimera 6 | fontFile= 7 | charSet=0 8 | fontSize=16 9 | aa=1 10 | scaleH=100 11 | useSmoothing=0 12 | isBold=0 13 | isItalic=0 14 | useUnicode=1 15 | disableBoxChars=1 16 | outputInvalidCharGlyph=0 17 | dontIncludeKerningPairs=0 18 | useHinting=1 19 | renderFromOutline=0 20 | useClearType=1 21 | 22 | # character alignment 23 | paddingDown=0 24 | paddingUp=0 25 | paddingRight=0 26 | paddingLeft=0 27 | spacingHoriz=1 28 | spacingVert=1 29 | useFixedHeight=1 30 | forceZero=0 31 | 32 | # output file 33 | outWidth=256 34 | outHeight=256 35 | outBitDepth=32 36 | fontDescFormat=0 37 | fourChnlPacked=0 38 | textureFormat=png 39 | textureCompression=0 40 | alphaChnl=0 41 | redChnl=4 42 | greenChnl=4 43 | blueChnl=4 44 | invA=0 45 | invR=0 46 | invG=0 47 | invB=0 48 | 49 | # outline 50 | outlineThickness=0 51 | 52 | # selected chars 53 | chars=32-126,161-167,169,171,176-177,183-189,191,215,247 54 | 55 | # imported icon images 56 | -------------------------------------------------------------------------------- /defrs/utils/rgb_hex.lua: -------------------------------------------------------------------------------- 1 | --- Convert between RGB colors and hex triplet colors 2 | -- hex value needs to be a string and should have a leading # 3 | -- RGB value can be either a string or a table 4 | -- #FFFFFF <-> 255,255,255 5 | 6 | local M = {} 7 | 8 | function M.hex_to_rgb(hex) 9 | hex = hex:gsub("#", "") -- remove the leading # symbol if there 10 | local rgb = {} 11 | rgb.r = tonumber("0x" .. hex:sub(1,2)) 12 | rgb.g = tonumber("0x" .. hex:sub(3,4)) 13 | rgb.b = tonumber("0x" .. hex:sub(5,6)) 14 | return rgb 15 | end 16 | 17 | function M.rgb_to_hex(rgb) 18 | local hex = "#" 19 | if type(rgb) == "string" then 20 | for color in rgb:gmatch("%d+") do 21 | hex = hex .. ("%X"):format(tostring(color)) 22 | end 23 | elseif type(rgb) == "table" then 24 | for _, color in pairs(rgb) do 25 | hex = hex .. ("%X"):format(tostring(color)) 26 | end 27 | end 28 | return hex 29 | end 30 | 31 | print(M.rgb_to_hex({255,255,255})) 32 | print(M.rgb_to_hex("255,255,255")) 33 | --newrgb = M.hex_to_rgb("#FFFFFF") 34 | --print(newrgb.r, newrgb.g, newrgb.b) 35 | 36 | return M 37 | -------------------------------------------------------------------------------- /examples/toys/random_level/random_level.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "components {\n" 6 | " id: \"tilemap\"\n" 7 | " component: \"/examples/toys/random_level/random_level.tilemap\"\n" 8 | " position {\n" 9 | " x: 0.0\n" 10 | " y: 0.0\n" 11 | " z: 0.0\n" 12 | " }\n" 13 | " rotation {\n" 14 | " x: 0.0\n" 15 | " y: 0.0\n" 16 | " z: 0.0\n" 17 | " w: 1.0\n" 18 | " }\n" 19 | "}\n" 20 | "components {\n" 21 | " id: \"script\"\n" 22 | " component: \"/examples/toys/random_level/random_level.script\"\n" 23 | " position {\n" 24 | " x: 0.0\n" 25 | " y: 0.0\n" 26 | " z: 0.0\n" 27 | " }\n" 28 | " rotation {\n" 29 | " x: 0.0\n" 30 | " y: 0.0\n" 31 | " z: 0.0\n" 32 | " w: 1.0\n" 33 | " }\n" 34 | "}\n" 35 | "" 36 | position { 37 | x: 0.0 38 | y: 0.0 39 | z: 0.0 40 | } 41 | rotation { 42 | x: 0.0 43 | y: 0.0 44 | z: 0.0 45 | w: 1.0 46 | } 47 | scale3 { 48 | x: 1.0 49 | y: 1.0 50 | z: 1.0 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /examples/toys/orbit/manager.script: -------------------------------------------------------------------------------- 1 | local orbs = {} 2 | 3 | local rng = require("defrs.utils.rng") 4 | 5 | function make_point(x,y) 6 | local count = #orbs + 1 7 | orbs[count] = factory.create("#factory", vmath.vector3(rng.random(25, 100), rng.random(25, 100), 0.0)) 8 | end 9 | 10 | 11 | 12 | 13 | function init(self) 14 | make_point() 15 | make_point() 16 | make_point() 17 | make_point() 18 | make_point() 19 | make_point() 20 | make_point() 21 | make_point() 22 | make_point() 23 | make_point() 24 | make_point() 25 | make_point() 26 | make_point() 27 | make_point() 28 | end 29 | 30 | function final(self) 31 | -- Add finalization code here 32 | -- Remove this function if not needed 33 | end 34 | 35 | function update(self, dt) 36 | -- Add update code here 37 | -- Remove this function if not needed 38 | end 39 | 40 | function on_message(self, message_id, message, sender) 41 | -- Add message-handling code here 42 | -- Remove this function if not needed 43 | end 44 | 45 | function on_input(self, action_id, action) 46 | -- Add input-handling code here 47 | -- Remove this function if not needed 48 | end 49 | 50 | function on_reload(self) 51 | -- Add reload-handling code here 52 | -- Remove this function if not needed 53 | end 54 | -------------------------------------------------------------------------------- /examples/toys/orbit/crosshair.script: -------------------------------------------------------------------------------- 1 | local mouse_helper = require("defrs.utils.mouse_helper") 2 | 3 | function init(self) 4 | -- Add initialization code here 5 | -- Remove this function if not needed 6 | msg.post(".", "acquire_input_focus") 7 | self.mouse_x, self.mouse_y = 0.0, 0.0 8 | msg.post("#sprite", "play_animation", {id = hash("crosshair_19")}) 9 | end 10 | 11 | function final(self) 12 | -- Add finalization code here 13 | -- Remove this function if not needed 14 | end 15 | 16 | function update(self, dt) 17 | -- Add update code here 18 | -- Remove this function if not needed 19 | go.set_position(vmath.vector3(mouse_helper.mouse_x, mouse_helper.mouse_y, 0.0)) 20 | 21 | end 22 | 23 | function on_message(self, message_id, message, sender) 24 | -- Add message-handling code here 25 | -- Remove this function if not needed 26 | end 27 | 28 | function on_input(self, action_id, action) 29 | mouse_helper.mouse_x, mouse_helper.mouse_y = action.x, action.y 30 | 31 | if action_id == hash("touch") and action.pressed then 32 | msg.post("#sprite", "play_animation", {id = hash("crosshair_19_fire")}) 33 | end 34 | --pprint(action) 35 | end 36 | 37 | function on_reload(self) 38 | -- Add reload-handling code here 39 | -- Remove this function if not needed 40 | end 41 | -------------------------------------------------------------------------------- /examples/toys/arc_swing/swing.script: -------------------------------------------------------------------------------- 1 | -- refactor = don't constantly create new vectors 2 | local swing_distance = 625 3 | 4 | function radian_to_vector(radian) 5 | return (vmath.vector3(math.cos(radian), math.sin(radian), 0.0)) 6 | end 7 | 8 | function init(self) 9 | go.set(".","scale.z",7 * math.pi / 6) 10 | go.animate(".","scale.z",go.PLAYBACK_LOOP_PINGPONG,11 * math.pi / 6,go.EASING_INOUTSINE,4) 11 | end 12 | 13 | function update(self, dt) 14 | local hanger_position = go.get_position("hanger") 15 | local position = hanger_position + radian_to_vector(go.get(".","scale.z")) * swing_distance 16 | go.set_position(position) 17 | end 18 | 19 | function on_message(self, message_id, message, sender) 20 | if message_id == hash("contact_point_response") then 21 | --pprint(message) 22 | --pprint(message.other_id) 23 | --msg.post(message.other_id, "apply_force", {force = vmath.vector3(10000.0, -10000, 0), position = go.get_position(message.other_id)}) 24 | msg.post(message.other_id, "apply_force", { force = message.normal * message.distance * -60000, position = message.position }) 25 | --msg.post("/bouncer_ball#collisionobject", "apply_force", { force = message.normal * message.distance * 100000, position = message.position }) 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /examples/input/4dir_move/4dir_move.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "components {\n" 6 | " id: \"script\"\n" 7 | " component: \"/examples/input/4dir_move/4dir_move.script\"\n" 8 | " position {\n" 9 | " x: 0.0\n" 10 | " y: 0.0\n" 11 | " z: 0.0\n" 12 | " }\n" 13 | " rotation {\n" 14 | " x: 0.0\n" 15 | " y: 0.0\n" 16 | " z: 0.0\n" 17 | " w: 1.0\n" 18 | " }\n" 19 | "}\n" 20 | "embedded_components {\n" 21 | " id: \"sprite\"\n" 22 | " type: \"sprite\"\n" 23 | " data: \"tile_set: \\\"/examples/toys/bouncer/logo.atlas\\\"\\n" 24 | "default_animation: \\\"logo\\\"\\n" 25 | "material: \\\"/builtins/materials/sprite.material\\\"\\n" 26 | "blend_mode: BLEND_MODE_ALPHA\\n" 27 | "\"\n" 28 | " position {\n" 29 | " x: 0.0\n" 30 | " y: 0.0\n" 31 | " z: 0.0\n" 32 | " }\n" 33 | " rotation {\n" 34 | " x: 0.0\n" 35 | " y: 0.0\n" 36 | " z: 0.0\n" 37 | " w: 1.0\n" 38 | " }\n" 39 | "}\n" 40 | "" 41 | position { 42 | x: 222.059 43 | y: 185.294 44 | z: 0.0 45 | } 46 | rotation { 47 | x: 0.0 48 | y: 0.0 49 | z: 0.0 50 | w: 1.0 51 | } 52 | scale3 { 53 | x: 1.0 54 | y: 1.0 55 | z: 1.0 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /examples/input/4dir_move/4dir_move.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | msg.post(".", "acquire_input_focus") 3 | self.direction = vmath.vector3(1,0,0) 4 | self.position = vmath.vector3(100,100,0) 5 | self.turn_speed = 0.09 6 | self.moving = false 7 | self.speed = 10 8 | go.set_position(self.position) 9 | end 10 | 11 | 12 | function update(self, dt) 13 | self.direction = vmath.normalize(self.direction) 14 | --pprint(self.direction) 15 | if self.moving == true then 16 | self.position = self.position + self.direction * self.speed 17 | go.set_position(self.position) 18 | end 19 | self.moving = false 20 | end 21 | 22 | 23 | function on_input(self, action_id, action) 24 | if action_id == hash("w") or action_id == hash("up") then 25 | self.direction.y = self.direction.y + self.turn_speed 26 | self.moving = true 27 | end 28 | if action_id == hash("a") or action_id == hash("left") then 29 | self.direction.x = self.direction.x - self.turn_speed 30 | self.moving = true 31 | end 32 | if action_id == hash("s") or action_id == hash("down") then 33 | self.direction.y = self.direction.y - self.turn_speed 34 | self.moving = true 35 | end 36 | if action_id == hash("d") or action_id == hash("right") then 37 | self.direction.x = self.direction.x + self.turn_speed 38 | self.moving = true 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /examples/tools/api_ext/api_ext.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "components {\n" 6 | " id: \"script\"\n" 7 | " component: \"/examples/tools/api_ext/api_ext.script\"\n" 8 | " position {\n" 9 | " x: 0.0\n" 10 | " y: 0.0\n" 11 | " z: 0.0\n" 12 | " }\n" 13 | " rotation {\n" 14 | " x: 0.0\n" 15 | " y: 0.0\n" 16 | " z: 0.0\n" 17 | " w: 1.0\n" 18 | " }\n" 19 | "}\n" 20 | "embedded_components {\n" 21 | " id: \"sprite\"\n" 22 | " type: \"sprite\"\n" 23 | " data: \"tile_set: \\\"/examples/toys/minesweeper/minesweeper_character.tilesource\\\"\\n" 24 | "default_animation: \\\"character_normal\\\"\\n" 25 | "material: \\\"/builtins/materials/sprite.material\\\"\\n" 26 | "blend_mode: BLEND_MODE_ALPHA\\n" 27 | "\"\n" 28 | " position {\n" 29 | " x: 105.983\n" 30 | " y: 111.111\n" 31 | " z: 0.0\n" 32 | " }\n" 33 | " rotation {\n" 34 | " x: 0.0\n" 35 | " y: 0.0\n" 36 | " z: 0.0\n" 37 | " w: 1.0\n" 38 | " }\n" 39 | "}\n" 40 | "" 41 | position { 42 | x: 0.0 43 | y: 0.0 44 | z: 0.0 45 | } 46 | rotation { 47 | x: 0.0 48 | y: 0.0 49 | z: 0.0 50 | w: 1.0 51 | } 52 | scale3 { 53 | x: 1.0 54 | y: 1.0 55 | z: 1.0 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /input/game.input_binding: -------------------------------------------------------------------------------- 1 | key_trigger { 2 | input: KEY_LALT 3 | action: "alt" 4 | } 5 | key_trigger { 6 | input: KEY_RALT 7 | action: "alt" 8 | } 9 | key_trigger { 10 | input: KEY_F4 11 | action: "f4" 12 | } 13 | key_trigger { 14 | input: KEY_UP 15 | action: "up" 16 | } 17 | key_trigger { 18 | input: KEY_DOWN 19 | action: "down" 20 | } 21 | key_trigger { 22 | input: KEY_LEFT 23 | action: "left" 24 | } 25 | key_trigger { 26 | input: KEY_RIGHT 27 | action: "right" 28 | } 29 | key_trigger { 30 | input: KEY_A 31 | action: "a" 32 | } 33 | key_trigger { 34 | input: KEY_B 35 | action: "b" 36 | } 37 | key_trigger { 38 | input: KEY_W 39 | action: "w" 40 | } 41 | key_trigger { 42 | input: KEY_S 43 | action: "s" 44 | } 45 | key_trigger { 46 | input: KEY_D 47 | action: "d" 48 | } 49 | key_trigger { 50 | input: KEY_ENTER 51 | action: "enter" 52 | } 53 | key_trigger { 54 | input: KEY_KP_ENTER 55 | action: "enter_kp" 56 | } 57 | key_trigger { 58 | input: KEY_BACKSPACE 59 | action: "backspace" 60 | } 61 | mouse_trigger { 62 | input: MOUSE_BUTTON_1 63 | action: "touch" 64 | } 65 | mouse_trigger { 66 | input: MOUSE_BUTTON_2 67 | action: "right_click" 68 | } 69 | touch_trigger { 70 | input: TOUCH_MULTI 71 | action: "multitouch" 72 | } 73 | text_trigger { 74 | input: TEXT 75 | action: "text" 76 | } 77 | -------------------------------------------------------------------------------- /defrs/utils/uuid.lua: -------------------------------------------------------------------------------- 1 | --- Generates UUIDs in version 4 format (randomly) only right now 2 | -- random seed is set once on module init 3 | 4 | M = {} 5 | 6 | function M.randomseed(seed) 7 | local bitsize = 32 8 | local lua_version = tonumber(_VERSION:match("%d%.*%d*")) 9 | seed = math.floor(math.abs(seed)) 10 | if seed >= (2^bitsize) then 11 | -- avoid overflow causing 1 or 0 as seed = repeated seeds 12 | seed = seed - math.floor(seed / 2^bitsize) * (2^bitsize) 13 | end 14 | if lua_version < 5.2 then 15 | -- 5.1 (incorrect) signed int 16 | math.randomseed(seed - 2^(bitsize-1)) 17 | else 18 | -- 5.2 (correct) unsigned int 19 | math.randomseed(seed) 20 | end 21 | return seed 22 | end 23 | 24 | function M.set_random_seed() 25 | M.randomseed(os.time()*10000) 26 | end 27 | 28 | function M.generate_UUID_version_4() 29 | local UUID_template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' 30 | return string.gsub(UUID_template, '[xy]', function (c) 31 | local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb) 32 | local UUID, _ = string.format('%x', v) 33 | return UUID 34 | end) 35 | end 36 | 37 | M.set_random_seed() 38 | M.dummy_UUID = M.generate_UUID_version_4() -- dump first random value 39 | 40 | 41 | --print(M.generate_UUID_version_4()) 42 | --UUID, _ = M.generate_UUID_version_4() 43 | --print(UUID) 44 | 45 | return M 46 | -------------------------------------------------------------------------------- /examples/toys/shooter/shooter_sprites.tilesource: -------------------------------------------------------------------------------- 1 | image: "/pyxels/shooter_sprites.png" 2 | tile_width: 32 3 | tile_height: 32 4 | tile_margin: 0 5 | tile_spacing: 0 6 | collision: "" 7 | material_tag: "tile" 8 | collision_groups: "default" 9 | animations { 10 | id: "anim" 11 | start_tile: 1 12 | end_tile: 1 13 | playback: PLAYBACK_ONCE_FORWARD 14 | fps: 30 15 | flip_horizontal: 0 16 | flip_vertical: 0 17 | } 18 | animations { 19 | id: "bullet" 20 | start_tile: 5 21 | end_tile: 5 22 | playback: PLAYBACK_ONCE_FORWARD 23 | fps: 30 24 | flip_horizontal: 0 25 | flip_vertical: 0 26 | } 27 | animations { 28 | id: "enemy_1" 29 | start_tile: 3 30 | end_tile: 3 31 | playback: PLAYBACK_ONCE_FORWARD 32 | fps: 30 33 | flip_horizontal: 0 34 | flip_vertical: 0 35 | } 36 | animations { 37 | id: "enemy_2" 38 | start_tile: 4 39 | end_tile: 4 40 | playback: PLAYBACK_ONCE_FORWARD 41 | fps: 30 42 | flip_horizontal: 0 43 | flip_vertical: 0 44 | } 45 | animations { 46 | id: "gun" 47 | start_tile: 2 48 | end_tile: 2 49 | playback: PLAYBACK_ONCE_FORWARD 50 | fps: 30 51 | flip_horizontal: 0 52 | flip_vertical: 0 53 | } 54 | animations { 55 | id: "player" 56 | start_tile: 1 57 | end_tile: 1 58 | playback: PLAYBACK_ONCE_FORWARD 59 | fps: 30 60 | flip_horizontal: 0 61 | flip_vertical: 0 62 | } 63 | extrude_borders: 2 64 | inner_padding: 0 65 | -------------------------------------------------------------------------------- /examples/tools/easing_equations/easing_equations.script: -------------------------------------------------------------------------------- 1 | local easing = require("defrs.utils.easing_equations") 2 | 3 | function init(self) 4 | self.timer = 0 5 | self.position = go.get_position("/visual") 6 | end 7 | 8 | function final(self) 9 | -- Add finalization code here 10 | -- Remove this function if not needed 11 | end 12 | 13 | function update(self, dt) 14 | 15 | 16 | self.timer = self.timer + dt 17 | 18 | local position = self.position 19 | 20 | 21 | position.y = easing.out_bounce(math.abs(math.sin(self.timer)),1,1.5,1) * -100 + 400 22 | 23 | 24 | go.set_position(position, "/visual") 25 | 26 | label.set_text("/labels#label",easing.out_bounce(math.abs(math.sin(self.timer)),1,1.5,1)) 27 | 28 | --easing.linear(math.abs(math.sin(self.timer),beginning_value,change,duration_total) 29 | --easing.out_bounce(time_current,beginning_value,change,duration_total) 30 | 31 | --easing.linear(time_current,beginning_value,change,duration_total) 32 | -- Remove this function if not needed 33 | end 34 | 35 | function on_message(self, message_id, message, sender) 36 | -- Add message-handling code here 37 | -- Remove this function if not needed 38 | end 39 | 40 | function on_input(self, action_id, action) 41 | -- Add input-handling code here 42 | -- Remove this function if not needed 43 | end 44 | 45 | function on_reload(self) 46 | -- Add reload-handling code here 47 | -- Remove this function if not needed 48 | end 49 | -------------------------------------------------------------------------------- /examples/toys/minesweeper/minesweeper_character.tilesource: -------------------------------------------------------------------------------- 1 | image: "/pyxels/minesweeper.png" 2 | tile_width: 64 3 | tile_height: 64 4 | tile_margin: 0 5 | tile_spacing: 0 6 | collision: "" 7 | material_tag: "tile" 8 | collision_groups: "default" 9 | animations { 10 | id: "character_dead" 11 | start_tile: 8 12 | end_tile: 8 13 | playback: PLAYBACK_LOOP_FORWARD 14 | fps: 30 15 | flip_horizontal: 0 16 | flip_vertical: 0 17 | } 18 | animations { 19 | id: "character_normal" 20 | start_tile: 5 21 | end_tile: 5 22 | playback: PLAYBACK_ONCE_FORWARD 23 | fps: 30 24 | flip_horizontal: 0 25 | flip_vertical: 0 26 | } 27 | animations { 28 | id: "character_pressed" 29 | start_tile: 6 30 | end_tile: 6 31 | playback: PLAYBACK_ONCE_FORWARD 32 | fps: 30 33 | flip_horizontal: 0 34 | flip_vertical: 0 35 | } 36 | animations { 37 | id: "character_win" 38 | start_tile: 9 39 | end_tile: 9 40 | playback: PLAYBACK_ONCE_FORWARD 41 | fps: 30 42 | flip_horizontal: 0 43 | flip_vertical: 0 44 | } 45 | animations { 46 | id: "character_worried" 47 | start_tile: 7 48 | end_tile: 7 49 | playback: PLAYBACK_ONCE_FORWARD 50 | fps: 30 51 | flip_horizontal: 0 52 | flip_vertical: 0 53 | } 54 | animations { 55 | id: "character_zombie" 56 | start_tile: 10 57 | end_tile: 10 58 | playback: PLAYBACK_ONCE_FORWARD 59 | fps: 30 60 | flip_horizontal: 0 61 | flip_vertical: 0 62 | } 63 | extrude_borders: 2 64 | inner_padding: 0 65 | -------------------------------------------------------------------------------- /examples/toys/bouncer/big_wall.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "embedded_components {\n" 6 | " id: \"collisionobject\"\n" 7 | " type: \"collisionobject\"\n" 8 | " data: \"collision_shape: \\\"\\\"\\n" 9 | "type: COLLISION_OBJECT_TYPE_STATIC\\n" 10 | "mass: 0.0\\n" 11 | "friction: 0.1\\n" 12 | "restitution: 0.5\\n" 13 | "group: \\\"default\\\"\\n" 14 | "mask: \\\"default\\\"\\n" 15 | "embedded_collision_shape {\\n" 16 | " shapes {\\n" 17 | " shape_type: TYPE_BOX\\n" 18 | " position {\\n" 19 | " x: 0.0\\n" 20 | " y: 0.0\\n" 21 | " z: 0.0\\n" 22 | " }\\n" 23 | " rotation {\\n" 24 | " x: 0.0\\n" 25 | " y: 0.0\\n" 26 | " z: 0.0\\n" 27 | " w: 1.0\\n" 28 | " }\\n" 29 | " index: 0\\n" 30 | " count: 3\\n" 31 | " }\\n" 32 | " data: 6239.8896\\n" 33 | " data: 6283.3467\\n" 34 | " data: 1.0\\n" 35 | "}\\n" 36 | "linear_damping: 0.0\\n" 37 | "angular_damping: 0.0\\n" 38 | "locked_rotation: false\\n" 39 | "\"\n" 40 | " position {\n" 41 | " x: 0.0\n" 42 | " y: 0.0\n" 43 | " z: 0.0\n" 44 | " }\n" 45 | " rotation {\n" 46 | " x: 0.0\n" 47 | " y: 0.0\n" 48 | " z: 0.0\n" 49 | " w: 1.0\n" 50 | " }\n" 51 | "}\n" 52 | "" 53 | position { 54 | x: 0.0 55 | y: 0.0 56 | z: 0.0 57 | } 58 | rotation { 59 | x: 0.0 60 | y: 0.0 61 | z: 0.0 62 | w: 1.0 63 | } 64 | scale3 { 65 | x: 1.0 66 | y: 1.0 67 | z: 1.0 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /examples/toys/konami_code/konami_code.script: -------------------------------------------------------------------------------- 1 | -- ↑ ↑ ↓ ↓ ← → ← → b a 2 | 3 | local colors = require("defrs.utils.colors") 4 | 5 | 6 | 7 | local sequence = {"up", "up", "down", "down", "left", "right", "left", "right", "b", "a"} 8 | 9 | function check_sequence(events, self) 10 | local matches = 0 11 | for key, value in ipairs(events) do 12 | if hash(sequence[key]) == value then 13 | matches = matches + 1 14 | else 15 | self.events = {} 16 | return false 17 | end 18 | if matches == #sequence then 19 | return true 20 | end 21 | end 22 | end 23 | 24 | function init(self) 25 | msg.post(".", "acquire_input_focus") 26 | self.events = {} 27 | 28 | self.timer = 0 29 | self.konami_code = false 30 | end 31 | 32 | 33 | function on_input(self, action_id, action) 34 | if action.released then 35 | local next_action = #self.events +1 36 | self.events[next_action] = hash(action_id) 37 | if(check_sequence(self.events, self)) then 38 | label.set_text("#label","Konami Code!") 39 | print("Konami Code!") 40 | particlefx.play("/victory#particlefx") 41 | self.events = {} 42 | self.konami_code = true 43 | go.animate(".","scale.x",go.PLAYBACK_LOOP_PINGPONG,5,go.EASING_INOUTEXPO,3) 44 | go.animate(".","scale.y",go.PLAYBACK_LOOP_PINGPONG,5.5,go.EASING_INOUTEXPO,3.1) 45 | msg.post("#sound", "play_sound", {delay = 0, gain = 0.5}) 46 | end 47 | pprint(self.events) 48 | end 49 | end 50 | 51 | function update(self, dt) 52 | self.timer = self.timer + dt 53 | 54 | if self.konami_code == true then 55 | go.set("#label","color",colors.get_random_color()) 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /examples/input/text_typing/text_typing.script: -------------------------------------------------------------------------------- 1 | local word_list_short = require("text.english_words_short") 2 | 3 | 4 | function init(self) 5 | math.randomseed( os.time() ) 6 | math.random();math.random();math.random(); 7 | -- Add initialization code here 8 | -- Remove this function if not needed 9 | msg.post(".", "acquire_input_focus") 10 | self.text_counter = 0 11 | self.last_text_counter = 0 12 | self.last_text = "" 13 | self.text = "" 14 | 15 | self.counter = 0 16 | 17 | self.word_list_count = #word_list_short 18 | end 19 | 20 | function final(self) 21 | -- Add finalization code here 22 | -- Remove this function if not needed 23 | end 24 | 25 | function update(self, dt) 26 | self.counter = self.counter + dt 27 | label.set_text("/_labels#label",self.text) 28 | 29 | if self.counter > 1 then 30 | self.counter = self.counter -1 31 | local random_word = word_list_short[math.random(1, self.word_list_count)] 32 | self.text = self.text .. " " .. random_word 33 | end 34 | end 35 | 36 | function on_message(self, message_id, message, sender) 37 | -- Add message-handling code here 38 | -- Remove this function if not needed 39 | end 40 | 41 | function on_input(self, action_id, action) 42 | if action_id == hash("text") then 43 | self.text = self.text .. action.text 44 | end 45 | if (action_id == hash("enter") or action_id == hash("enter_kp")) and action.released then 46 | self.text = self.text .. "\n" 47 | end 48 | if action_id == hash("backspace") and action.released then 49 | self.text = self.text:sub(1, -2) 50 | end 51 | -- Add input-handling code here 52 | -- Remove this function if not needed 53 | end 54 | 55 | function on_reload(self) 56 | -- Add reload-handling code here 57 | -- Remove this function if not needed 58 | end 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DefRS 2 | A collection of useful general resources made ready to be used with the Defold game engine 3 | 4 | The purpose of this resource collection is to help speed up workflows for new projects, and help new users to learn useful techniques. 5 | 6 | The license for the files included are [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/) unless otherwise noted. 7 | 8 | ## Installation 9 | You can use DefRS in your own project by adding this project as a [Defold library dependency](http://www.defold.com/manuals/libraries/). Open your game.project file and in the dependencies field under project add: 10 | 11 | https://github.com/subsoap/defrs/archive/master.zip 12 | 13 | Once installed, you can use the resources you wish to use from their associated folders much like you would builtin resources. When you make builds Defold will only package the files you actually use so do not worry about the extra files included. Check your build folder to see for yourself. 14 | 15 | Check the source files and examples for full usage. 16 | 17 | ## Toys 18 | * Swing of an arc (arc_swing) 19 | * Random and seed based generation of identicons 20 | * Space movement showing moving by vectors (orbit) 21 | * Classic RPG style tile movement 22 | 23 | ## Utils 24 | * Set of easy to use colors 25 | * Mersenne Twister PRNG 26 | 27 | ## Input 28 | 29 | * Handling Alt+F4 to close game on Windows 30 | * Multitouch with unique ID for each finger 31 | * Detecting the konami code or other cheat codes 32 | 33 | ## Effects 34 | 35 | * How to make a spinning spell aura in orthographic view 36 | 37 | ## Particle FX 38 | 39 | ## Helper Scripts 40 | * Set scale of GO based on properties 41 | * Set color tint of Sprite based on properties 42 | 43 | 44 | ## Templates 45 | -------------------------------------------------------------------------------- /examples/toys/arc_swing/bouncer_ball.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "script" 3 | component: "/defrs/scripts/sprite_set_tint_color.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | properties { 16 | id: "tint" 17 | value: "0.9,0.9,1.0,1.0" 18 | type: PROPERTY_TYPE_VECTOR4 19 | } 20 | } 21 | embedded_components { 22 | id: "collisionobject" 23 | type: "collisionobject" 24 | data: "collision_shape: \"\"\n" 25 | "type: COLLISION_OBJECT_TYPE_DYNAMIC\n" 26 | "mass: 70.0\n" 27 | "friction: 0.01\n" 28 | "restitution: 0.8\n" 29 | "group: \"default\"\n" 30 | "mask: \"default\"\n" 31 | "embedded_collision_shape {\n" 32 | " shapes {\n" 33 | " shape_type: TYPE_SPHERE\n" 34 | " position {\n" 35 | " x: 0.0\n" 36 | " y: 0.0\n" 37 | " z: 0.0\n" 38 | " }\n" 39 | " rotation {\n" 40 | " x: 0.0\n" 41 | " y: 0.0\n" 42 | " z: 0.0\n" 43 | " w: 1.0\n" 44 | " }\n" 45 | " index: 0\n" 46 | " count: 1\n" 47 | " }\n" 48 | " data: 55.0\n" 49 | "}\n" 50 | "linear_damping: 0.0\n" 51 | "angular_damping: 0.0\n" 52 | "locked_rotation: false\n" 53 | "" 54 | position { 55 | x: 0.0 56 | y: 0.0 57 | z: 0.0 58 | } 59 | rotation { 60 | x: 0.0 61 | y: 0.0 62 | z: 0.0 63 | w: 1.0 64 | } 65 | } 66 | embedded_components { 67 | id: "sprite" 68 | type: "sprite" 69 | data: "tile_set: \"/defrs/assets/textures/misc/misc.atlas\"\n" 70 | "default_animation: \"pearl\"\n" 71 | "material: \"/builtins/materials/sprite.material\"\n" 72 | "blend_mode: BLEND_MODE_ALPHA\n" 73 | "" 74 | position { 75 | x: 0.0 76 | y: 0.0 77 | z: 0.0 78 | } 79 | rotation { 80 | x: 0.0 81 | y: 0.0 82 | z: 0.0 83 | w: 1.0 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /examples/toys/rpg_movement/critters.tilesource: -------------------------------------------------------------------------------- 1 | image: "/pyxels/critters2.png" 2 | tile_width: 32 3 | tile_height: 32 4 | tile_margin: 0 5 | tile_spacing: 0 6 | collision: "" 7 | material_tag: "tile" 8 | animations { 9 | id: "bird_down" 10 | start_tile: 5 11 | end_tile: 5 12 | playback: PLAYBACK_ONCE_FORWARD 13 | fps: 30 14 | flip_horizontal: 0 15 | flip_vertical: 0 16 | } 17 | animations { 18 | id: "bunny_down" 19 | start_tile: 1 20 | end_tile: 1 21 | playback: PLAYBACK_ONCE_FORWARD 22 | fps: 30 23 | flip_horizontal: 0 24 | flip_vertical: 0 25 | } 26 | animations { 27 | id: "bunny_left" 28 | start_tile: 11 29 | end_tile: 11 30 | playback: PLAYBACK_ONCE_FORWARD 31 | fps: 30 32 | flip_horizontal: 0 33 | flip_vertical: 0 34 | } 35 | animations { 36 | id: "bunny_moving_down" 37 | start_tile: 1 38 | end_tile: 2 39 | playback: PLAYBACK_LOOP_FORWARD 40 | fps: 10 41 | flip_horizontal: 0 42 | flip_vertical: 0 43 | } 44 | animations { 45 | id: "bunny_moving_left" 46 | start_tile: 11 47 | end_tile: 12 48 | playback: PLAYBACK_LOOP_FORWARD 49 | fps: 10 50 | flip_horizontal: 0 51 | flip_vertical: 0 52 | } 53 | animations { 54 | id: "bunny_moving_right" 55 | start_tile: 3 56 | end_tile: 4 57 | playback: PLAYBACK_LOOP_FORWARD 58 | fps: 10 59 | flip_horizontal: 0 60 | flip_vertical: 0 61 | } 62 | animations { 63 | id: "bunny_moving_up" 64 | start_tile: 9 65 | end_tile: 10 66 | playback: PLAYBACK_LOOP_FORWARD 67 | fps: 10 68 | flip_horizontal: 0 69 | flip_vertical: 0 70 | } 71 | animations { 72 | id: "bunny_right" 73 | start_tile: 3 74 | end_tile: 3 75 | playback: PLAYBACK_ONCE_FORWARD 76 | fps: 30 77 | flip_horizontal: 0 78 | flip_vertical: 0 79 | } 80 | animations { 81 | id: "bunny_up" 82 | start_tile: 9 83 | end_tile: 9 84 | playback: PLAYBACK_ONCE_FORWARD 85 | fps: 30 86 | flip_horizontal: 0 87 | flip_vertical: 0 88 | } 89 | extrude_borders: 2 90 | inner_padding: 0 91 | -------------------------------------------------------------------------------- /defrs/utils/prettify.lua: -------------------------------------------------------------------------------- 1 | --- Module to prettify/format structured data in a way that makes it easier to 2 | -- read for a human. 3 | -- The module can currently prettify Lua tables. 4 | -- @usage 5 | -- require "prettify" 6 | -- local foo = { some = "data" } 7 | -- print(prettify(foo)) 8 | 9 | local M = {} 10 | 11 | M.indentation = " " 12 | 13 | --- Prettify a table 14 | -- @param data 15 | -- @return Prettified table 16 | function M.prettify_table(data) 17 | local encountered_tables = {} 18 | local indentation = M.indentation 19 | local current_indentation = "" 20 | local result = "" 21 | 22 | local function indent_more() 23 | current_indentation = current_indentation .. indentation 24 | end 25 | 26 | local function indent_less() 27 | current_indentation = current_indentation:sub(1, #current_indentation - #indentation) 28 | end 29 | 30 | local function add_line(line) 31 | result = result .. current_indentation .. line .. "\n" 32 | end 33 | 34 | local function format_table(value) 35 | add_line("{") 36 | indent_more() 37 | for name,data in pairs(value) do 38 | if type(name) == "string" then 39 | name = '"'..name..'"' 40 | else 41 | name = tostring(name) 42 | end 43 | local dt = type(data) 44 | if dt == "table" then 45 | if not encountered_tables[data] then 46 | encountered_tables[data] = true 47 | add_line(name .. " = [".. tostring(data) .. "]") 48 | format_table(data) 49 | else 50 | add_line(name .. " = [".. tostring(data) .. "] (Circular reference)") 51 | end 52 | elseif dt == "string" then 53 | add_line(name .. ' = "' .. tostring(data) .. '"') 54 | else 55 | add_line(name .. " = " .. tostring(data)) 56 | end 57 | end 58 | indent_less() 59 | add_line("}") 60 | end 61 | 62 | if type(data) == "table" then 63 | format_table(data) 64 | else 65 | result = tostring(data) 66 | end 67 | return result 68 | end 69 | 70 | 71 | return setmetatable(M, { 72 | __call = function(self, ...) 73 | return M.prettify_table(...) 74 | end, 75 | }) 76 | -------------------------------------------------------------------------------- /defrs/scripts/handle_alt_f4.script: -------------------------------------------------------------------------------- 1 | -- This shows you how to detect a user pressing Alt+F4, which is a common way to force close a program on Windows 2 | -- General behavior for Alt+F4 is to be instant close without waiting for action.pressed on F4 3 | -- You may wish to instead show a dialog and let user confirm closing, but instant close is best 4 | -- Make sure you save user data properly before closing if so you'll want to make a copy of this script to customize 5 | -- If you are publishing on Windows then you want to include this as an option 6 | -- You can also detect Alt+Enter in a similar way - it is a common way to toggle fullscreen mode in Windows programs 7 | -- You can toggle between window mode and fullscreen with DefOS 8 | -- Your game.input_binding must have alt and f4 9 | --[[ 10 | key_trigger { 11 | input: KEY_LALT 12 | action: "alt" 13 | } 14 | key_trigger { 15 | input: KEY_RALT 16 | action: "alt" 17 | } 18 | key_trigger { 19 | input: KEY_F4 20 | action: "f4" 21 | } 22 | --]] 23 | 24 | 25 | function init(self) 26 | msg.post(".", "acquire_input_focus") 27 | self.alt_held_down = false 28 | self.sysinfo = sys.get_sys_info() 29 | end 30 | 31 | function on_input(self, action_id, action) 32 | if self.sysinfo.system_name == "Windows" then 33 | if action_id == hash("alt") then 34 | self.alt_held_down = true 35 | end 36 | if action_id == hash("alt") and action.released then 37 | self.alt_held_down = false 38 | end 39 | if action_id == hash("f4") and self.alt_held_down then 40 | msg.post("@system:", "exit", {code = 0}) 41 | end 42 | end 43 | end 44 | 45 | 46 | --[[ 47 | function on_input(self, action_id, action) 48 | sysinfo.system_name == "Windows" then 49 | if action_id == hash("alt") then 50 | self.alt_held_down = true 51 | print("alt held down") 52 | end 53 | if action_id == hash("alt") and action.released then 54 | self.alt_held_down = false 55 | print("releaseing alt") 56 | end 57 | if action_id == hash("f4") and self.alt_held_down then 58 | print("show confirm dialog to close game") 59 | end 60 | if action_id == hash("f4") and action.pressed then 61 | print("f4") 62 | end 63 | end 64 | end 65 | --]] -------------------------------------------------------------------------------- /examples/_render/default.render_script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.tile_pred = render.predicate({"tile"}) 3 | self.gui_pred = render.predicate({"gui"}) 4 | self.text_pred = render.predicate({"text"}) 5 | self.particle_pred = render.predicate({"particle"}) 6 | 7 | self.clear_color = vmath.vector4(0, 0, 0, 0) 8 | self.clear_color.x = sys.get_config("render.clear_color_red", 0) 9 | self.clear_color.y = sys.get_config("render.clear_color_green", 0) 10 | self.clear_color.z = sys.get_config("render.clear_color_blue", 0) 11 | self.clear_color.w = sys.get_config("render.clear_color_alpha", 0) 12 | 13 | self.view = vmath.matrix4() 14 | end 15 | 16 | function update(self) 17 | render.set_depth_mask(true) 18 | render.set_stencil_mask(0xff) 19 | render.clear({[render.BUFFER_COLOR_BIT] = self.clear_color, [render.BUFFER_DEPTH_BIT] = 1, [render.BUFFER_STENCIL_BIT] = 0}) 20 | 21 | render.set_viewport(0, 0, render.get_window_width(), render.get_window_height()) 22 | render.set_view(self.view) 23 | 24 | render.set_depth_mask(false) 25 | render.disable_state(render.STATE_DEPTH_TEST) 26 | render.disable_state(render.STATE_STENCIL_TEST) 27 | render.enable_state(render.STATE_BLEND) 28 | render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA) 29 | render.disable_state(render.STATE_CULL_FACE) 30 | 31 | render.set_projection(vmath.matrix4_orthographic(0, render.get_width(), 0, render.get_height(), -1000, 1000)) 32 | 33 | render.draw(self.tile_pred) 34 | render.draw(self.particle_pred) 35 | render.draw_debug3d() 36 | 37 | render.set_view(vmath.matrix4()) 38 | render.set_projection(vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1)) 39 | 40 | render.enable_state(render.STATE_STENCIL_TEST) 41 | render.draw(self.gui_pred) 42 | render.draw(self.text_pred) 43 | render.disable_state(render.STATE_STENCIL_TEST) 44 | 45 | render.set_depth_mask(false) 46 | render.draw_debug2d() 47 | end 48 | 49 | function on_message(self, message_id, message) 50 | if message_id == hash("clear_color") then 51 | self.clear_color = message.color 52 | elseif message_id == hash("set_view_projection") then 53 | self.view = message.view 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /examples/tools/ms_rng/ms_rng.script: -------------------------------------------------------------------------------- 1 | local ms_rng = require("defrs.utils.mersennetwister") 2 | 3 | 4 | 5 | function init(self) 6 | 7 | ms_rng.seed_mt() 8 | -- 0 to 1, add more zeroes if needed 9 | print(ms_rng.random(0,1000) * 0.001) 10 | print(ms_rng.random(0,1000) * 0.001) 11 | print(ms_rng.random(0,1000) * 0.001) 12 | print(ms_rng.random(0,1000) * 0.001) 13 | print(ms_rng.random(0,1000) * 0.001) 14 | 15 | -- set seed, if seed is not set it will use os.time as seed 16 | ms_rng.seed_mt(777) 17 | -- min, max value 18 | -- what you want most of the time 19 | print(ms_rng.random(0,100)) 20 | print(ms_rng.random(0,100)) 21 | print(ms_rng.random(0,100)) 22 | print(ms_rng.random(0,100)) 23 | print(ms_rng.random(0,100)) 24 | 25 | ms_rng.seed_mt(777) 26 | print(ms_rng.random(1)) 27 | print(ms_rng.random(2)) 28 | print(ms_rng.random(3)) 29 | print(ms_rng.random(4)) 30 | print(ms_rng.random(5)) 31 | print(ms_rng.random(1)) 32 | print(ms_rng.random(2)) 33 | print(ms_rng.random(3)) 34 | print(ms_rng.random(4)) 35 | print(ms_rng.random(5)) 36 | print(ms_rng.random(1)) 37 | print(ms_rng.random(2)) 38 | print(ms_rng.random(3)) 39 | print(ms_rng.random(4)) 40 | print(ms_rng.random(5)) 41 | 42 | ms_rng.seed_mt(777) 43 | print(ms_rng.random()) 44 | print(ms_rng.random()) 45 | print(ms_rng.random()) 46 | print(ms_rng.random()) 47 | print(ms_rng.random()) 48 | print(ms_rng.random()) 49 | print(ms_rng.random()) 50 | print(ms_rng.random()) 51 | print(ms_rng.random()) 52 | print(ms_rng.random()) 53 | print(ms_rng.random()) 54 | print(ms_rng.random()) 55 | print(ms_rng.random()) 56 | print(ms_rng.random()) 57 | print(ms_rng.random()) 58 | 59 | end 60 | 61 | function final(self) 62 | -- Add finalization code here 63 | -- Remove this function if not needed 64 | end 65 | 66 | function update(self, dt) 67 | -- Add update code here 68 | -- Remove this function if not needed 69 | end 70 | 71 | function on_message(self, message_id, message, sender) 72 | -- Add message-handling code here 73 | -- Remove this function if not needed 74 | end 75 | 76 | function on_input(self, action_id, action) 77 | -- Add input-handling code here 78 | -- Remove this function if not needed 79 | end 80 | 81 | function on_reload(self) 82 | -- Add reload-handling code here 83 | -- Remove this function if not needed 84 | end 85 | -------------------------------------------------------------------------------- /examples/tools/ms_rng/ms_rng.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "ms_rng" 5 | children: "labels" 6 | data: "components {\n" 7 | " id: \"script\"\n" 8 | " component: \"/examples/tools/ms_rng/ms_rng.script\"\n" 9 | " position {\n" 10 | " x: 0.0\n" 11 | " y: 0.0\n" 12 | " z: 0.0\n" 13 | " }\n" 14 | " rotation {\n" 15 | " x: 0.0\n" 16 | " y: 0.0\n" 17 | " z: 0.0\n" 18 | " w: 1.0\n" 19 | " }\n" 20 | "}\n" 21 | "" 22 | position { 23 | x: 0.0 24 | y: 0.0 25 | z: 0.0 26 | } 27 | rotation { 28 | x: 0.0 29 | y: 0.0 30 | z: 0.0 31 | w: 1.0 32 | } 33 | scale3 { 34 | x: 1.0 35 | y: 1.0 36 | z: 1.0 37 | } 38 | } 39 | embedded_instances { 40 | id: "labels" 41 | data: "embedded_components {\n" 42 | " id: \"label\"\n" 43 | " type: \"label\"\n" 44 | " data: \"size {\\n" 45 | " x: 128.0\\n" 46 | " y: 32.0\\n" 47 | " z: 0.0\\n" 48 | " w: 0.0\\n" 49 | "}\\n" 50 | "scale {\\n" 51 | " x: 1.0\\n" 52 | " y: 1.0\\n" 53 | " z: 1.0\\n" 54 | " w: 0.0\\n" 55 | "}\\n" 56 | "color {\\n" 57 | " x: 1.0\\n" 58 | " y: 1.0\\n" 59 | " z: 1.0\\n" 60 | " w: 1.0\\n" 61 | "}\\n" 62 | "outline {\\n" 63 | " x: 0.0\\n" 64 | " y: 0.0\\n" 65 | " z: 0.0\\n" 66 | " w: 1.0\\n" 67 | "}\\n" 68 | "shadow {\\n" 69 | " x: 0.0\\n" 70 | " y: 0.0\\n" 71 | " z: 0.0\\n" 72 | " w: 1.0\\n" 73 | "}\\n" 74 | "leading: 1.0\\n" 75 | "tracking: 0.0\\n" 76 | "pivot: PIVOT_CENTER\\n" 77 | "blend_mode: BLEND_MODE_ALPHA\\n" 78 | "line_break: false\\n" 79 | "text: \\\"Read the console.\\\"\\n" 80 | "font: \\\"/defrs/fonts/nes_chimera/nes_chimera.font\\\"\\n" 81 | "material: \\\"/defrs/fonts/materials/pixel_font.material\\\"\\n" 82 | "\"\n" 83 | " position {\n" 84 | " x: 0.0\n" 85 | " y: 0.0\n" 86 | " z: 0.0\n" 87 | " }\n" 88 | " rotation {\n" 89 | " x: 0.0\n" 90 | " y: 0.0\n" 91 | " z: 0.0\n" 92 | " w: 1.0\n" 93 | " }\n" 94 | "}\n" 95 | "" 96 | position { 97 | x: 768.756 98 | y: 397.632 99 | z: 0.0 100 | } 101 | rotation { 102 | x: 0.0 103 | y: 0.0 104 | z: 0.0 105 | w: 1.0 106 | } 107 | scale3 { 108 | x: 1.0 109 | y: 1.0 110 | z: 1.0 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /examples/toys/minesweeper/minesweeper_numbers.tilesource: -------------------------------------------------------------------------------- 1 | image: "/pyxels/minesweeper.png" 2 | tile_width: 32 3 | tile_height: 64 4 | tile_margin: 0 5 | tile_spacing: 0 6 | collision: "" 7 | material_tag: "tile" 8 | collision_groups: "default" 9 | animations { 10 | id: "number_0" 11 | start_tile: 22 12 | end_tile: 22 13 | playback: PLAYBACK_ONCE_FORWARD 14 | fps: 30 15 | flip_horizontal: 0 16 | flip_vertical: 0 17 | } 18 | animations { 19 | id: "number_1" 20 | start_tile: 23 21 | end_tile: 23 22 | playback: PLAYBACK_ONCE_FORWARD 23 | fps: 30 24 | flip_horizontal: 0 25 | flip_vertical: 0 26 | } 27 | animations { 28 | id: "number_2" 29 | start_tile: 24 30 | end_tile: 24 31 | playback: PLAYBACK_ONCE_FORWARD 32 | fps: 30 33 | flip_horizontal: 0 34 | flip_vertical: 0 35 | } 36 | animations { 37 | id: "number_3" 38 | start_tile: 25 39 | end_tile: 25 40 | playback: PLAYBACK_ONCE_FORWARD 41 | fps: 30 42 | flip_horizontal: 0 43 | flip_vertical: 0 44 | } 45 | animations { 46 | id: "number_4" 47 | start_tile: 26 48 | end_tile: 26 49 | playback: PLAYBACK_ONCE_FORWARD 50 | fps: 30 51 | flip_horizontal: 0 52 | flip_vertical: 0 53 | } 54 | animations { 55 | id: "number_5" 56 | start_tile: 27 57 | end_tile: 27 58 | playback: PLAYBACK_ONCE_FORWARD 59 | fps: 30 60 | flip_horizontal: 0 61 | flip_vertical: 0 62 | } 63 | animations { 64 | id: "number_6" 65 | start_tile: 28 66 | end_tile: 28 67 | playback: PLAYBACK_ONCE_FORWARD 68 | fps: 30 69 | flip_horizontal: 0 70 | flip_vertical: 0 71 | } 72 | animations { 73 | id: "number_7" 74 | start_tile: 29 75 | end_tile: 29 76 | playback: PLAYBACK_ONCE_FORWARD 77 | fps: 30 78 | flip_horizontal: 0 79 | flip_vertical: 0 80 | } 81 | animations { 82 | id: "number_8" 83 | start_tile: 30 84 | end_tile: 30 85 | playback: PLAYBACK_ONCE_FORWARD 86 | fps: 30 87 | flip_horizontal: 0 88 | flip_vertical: 0 89 | } 90 | animations { 91 | id: "number_9" 92 | start_tile: 31 93 | end_tile: 31 94 | playback: PLAYBACK_ONCE_FORWARD 95 | fps: 30 96 | flip_horizontal: 0 97 | flip_vertical: 0 98 | } 99 | animations { 100 | id: "number_off" 101 | start_tile: 21 102 | end_tile: 21 103 | playback: PLAYBACK_ONCE_FORWARD 104 | fps: 30 105 | flip_horizontal: 0 106 | flip_vertical: 0 107 | } 108 | extrude_borders: 2 109 | inner_padding: 0 110 | -------------------------------------------------------------------------------- /defrs/utils/mersennetwister.lua: -------------------------------------------------------------------------------- 1 | -- Based on: 2 | -- MT19937: 32-bit Mersenne Twister by Matsumoto and Nishimura, 1998 3 | -- http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/ARTICLES/mt.pdf 4 | -- https://en.wikipedia.org/wiki/Mersenne_Twister 5 | -- This work is licensed under the Creative Commons Attribution 4.0 International License. 6 | -- To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/. 7 | -- Author: Mr Doomah - with slight modifications 8 | 9 | local M = {} 10 | 11 | 12 | local w, n, m, r = 32, 624, 397, 31 13 | local a = 0x9908B0DF 14 | local u = 11 15 | local s, b = 7, 0x9D2C5680 16 | local t, c = 15, 0xEFC60000 17 | local l = 18 18 | local f = 1812433253 19 | 20 | -- Assign functions 21 | local bnot = bit.bnot 22 | local bxor = bit.bxor 23 | local band = bit.band 24 | local bor = bit.bor 25 | local rshift = bit.rshift 26 | local lshift = bit.lshift 27 | local function int32(int) -- 32 bits 28 | return band(int, 0xFFFFFFFF) 29 | end 30 | 31 | -- Create an array to store the state of the generator 32 | local MT = {} 33 | local index = n+1 34 | local lower_mask = lshift(1, r) -1 35 | local upper_mask = int32(bnot(lower_mask)) 36 | 37 | -- Initialize the generator from a seed 38 | function M.seed_mt(seed) 39 | index = n 40 | if not seed then seed = os.time() end 41 | MT[0] = int32(seed) 42 | for i = 1, n-1 do 43 | MT[i] = int32(f * bxor(MT[i-1], rshift(MT[i-1], w-2) + i)) 44 | end 45 | end 46 | 47 | -- Extract a tempered value based on MT[index] 48 | -- calling M.twist() every n numbers 49 | function M.extract_number() 50 | if index >= n then 51 | if index > n then 52 | M.seed_mt() 53 | end 54 | M.twist() 55 | end 56 | 57 | local y = MT[index] 58 | y = bxor(y, rshift(y, u)) 59 | y = bxor(y, band(lshift(y, s), b)) 60 | y = bxor(y, band(lshift(y, t), c)) 61 | y = bxor(y, rshift(y, l)) 62 | 63 | index = index+1 64 | return int32(y) 65 | end 66 | 67 | -- Generate the next n values from the series x_i 68 | function M.twist() 69 | for i = 0, n-1 do 70 | local x = bor(band(MT[i], upper_mask), band(MT[(i+1) % n], lower_mask)) 71 | local xA = rshift(x, 1) 72 | if x % 2 ~= 0 then 73 | xA = bxor(xA, a) 74 | end 75 | MT[i] = int32(bxor(MT[(i + m) % n], xA)) 76 | end 77 | index = 0 78 | end 79 | 80 | -- Function to call to get a random number 81 | function M.random(p, q) 82 | if p then 83 | if q then 84 | return p + M.extract_number() % (q - p + 1) 85 | else 86 | return 1 + M.extract_number() % p 87 | end 88 | else 89 | return M.extract_number() / 0xFFFFFFFF 90 | end 91 | end 92 | 93 | return M -------------------------------------------------------------------------------- /examples/toys/bouncer/ground.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "ground" 5 | children: "image_container" 6 | data: "embedded_components {\n" 7 | " id: \"collisionobject\"\n" 8 | " type: \"collisionobject\"\n" 9 | " data: \"collision_shape: \\\"\\\"\\n" 10 | "type: COLLISION_OBJECT_TYPE_STATIC\\n" 11 | "mass: 0.0\\n" 12 | "friction: 0.1\\n" 13 | "restitution: 0.5\\n" 14 | "group: \\\"default\\\"\\n" 15 | "mask: \\\"default\\\"\\n" 16 | "embedded_collision_shape {\\n" 17 | " shapes {\\n" 18 | " shape_type: TYPE_BOX\\n" 19 | " position {\\n" 20 | " x: 0.0\\n" 21 | " y: 0.0\\n" 22 | " z: 0.0\\n" 23 | " }\\n" 24 | " rotation {\\n" 25 | " x: 0.0\\n" 26 | " y: 0.0\\n" 27 | " z: 0.0\\n" 28 | " w: 1.0\\n" 29 | " }\\n" 30 | " index: 0\\n" 31 | " count: 3\\n" 32 | " }\\n" 33 | " data: 63.675686\\n" 34 | " data: 10.0\\n" 35 | " data: 500.0\\n" 36 | "}\\n" 37 | "linear_damping: 0.0\\n" 38 | "angular_damping: 0.0\\n" 39 | "locked_rotation: false\\n" 40 | "\"\n" 41 | " position {\n" 42 | " x: 0.0\n" 43 | " y: 0.0\n" 44 | " z: 0.0\n" 45 | " }\n" 46 | " rotation {\n" 47 | " x: 0.0\n" 48 | " y: 0.0\n" 49 | " z: 0.0\n" 50 | " w: 1.0\n" 51 | " }\n" 52 | "}\n" 53 | "" 54 | position { 55 | x: 0.0 56 | y: 0.0 57 | z: 0.0 58 | } 59 | rotation { 60 | x: 0.0 61 | y: 0.0 62 | z: 0.0 63 | w: 1.0 64 | } 65 | scale3 { 66 | x: 1.0 67 | y: 1.0 68 | z: 1.0 69 | } 70 | } 71 | embedded_instances { 72 | id: "image_container" 73 | data: "embedded_components {\n" 74 | " id: \"sprite\"\n" 75 | " type: \"sprite\"\n" 76 | " data: \"tile_set: \\\"/examples/toys/bouncer/logo.atlas\\\"\\n" 77 | "default_animation: \\\"logo\\\"\\n" 78 | "material: \\\"/builtins/materials/sprite.material\\\"\\n" 79 | "blend_mode: BLEND_MODE_ALPHA\\n" 80 | "\"\n" 81 | " position {\n" 82 | " x: 0.0\n" 83 | " y: 0.0\n" 84 | " z: 0.0\n" 85 | " }\n" 86 | " rotation {\n" 87 | " x: 0.0\n" 88 | " y: 0.0\n" 89 | " z: 0.0\n" 90 | " w: 1.0\n" 91 | " }\n" 92 | "}\n" 93 | "" 94 | position { 95 | x: 0.0 96 | y: 0.0 97 | z: 0.0 98 | } 99 | rotation { 100 | x: 0.0 101 | y: 0.0 102 | z: 0.0 103 | w: 1.0 104 | } 105 | scale3 { 106 | x: 1.0 107 | y: 0.154866 108 | z: 1.0 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /examples/tools/html_run_code/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 |