1
Game art & music / Re: LOZ- GBA Style
« on: September 25, 2019, 07:31:55 PM »
Welcome. Are you contributing specifically to GregoryMcGregorson's Minish Resource pack?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
require("scripts/multi_events")
local game_meta = sol.main.get_metatable("game")
local function game_over_restart_game(game)
game:start()
game:set_hud_enabled(true)
end
local function game_restart_hud(game)
game:set_hud_enabled(true)
end
game_meta:register_event("on_game_over_started", game_over_restart_game)
game_meta:register_event("on_started", game_restart_hud)
require("scripts/multi_events")
local game_meta = sol.main.get_metatable("game")
function game_meta:on_command_pressed(command)
if command == "right" then
if self:is_command_pressed("up") then
self:simulate_command_released("up")
end
if self:is_command_pressed("down") then
self:simulate_command_released("down")
end
end
if command == "left" then
if self:is_command_pressed("up") then
self:simulate_command_released("up")
end
if self:is_command_pressed("down") then
self:simulate_command_released("down")
end
end
if command == "up" then
if self:is_command_pressed("left") then
self:simulate_command_released("left")
end
if self:is_command_pressed("right") then
self:simulate_command_released("right")
end
end
if command == "down" then
if self:is_command_pressed("left") then
self:simulate_command_released("left")
end
if self:is_command_pressed("right") then
self:simulate_command_released("right")
end
end
--Optionally, this disables the spin attack (or anything which would come after a normal attack)
if command == "attack" then
self:simulate_command_released("attack")
end
end
require("scripts/multi_events") --This is required for this script to work. It allows the script to be called on its own.
local game_meta = sol.main.get_metatable("game")
local function set_camera(game)
if game ~= nil then
if game:get_map() ~= nil then
local map = game:get_map()
local camera = map:get_camera()
camera:set_size(256, 160)
--camera:set_position_on_screen(0, 16)
end
end
end
game_meta:register_event("on_map_changed", set_camera)
require("scripts/multi_events") --This is required for this script to work. It allows the script to be called on its own.
print("Hello") --Used for testing
local map_meta = sol.main.get_metatable("map")
map_meta:register_event("on started", function()
camera = self.get_camera()
camera:set_size(256, 160)
camera:set_position_on_screen(0, 16)
print("World") --Used for testing
end)
-- Somewhere in your main script, at initialization time:
local map_metatable = sol.main.get_metatable("map")
function map_metatable:add_overlay(image_file_name)
-- Here, self is the map.
self.overlay = sol.surface.create(image_file_name)
end
function map_metatable:on_draw(dst_surface)
if self.overlay ~= nil then
self.overlay:draw(dst_surface)
end
end
-- Now, all your maps will have a function map:add_overlay() and an event
-- map:on_draw() that allows to draw an additional image above the map!