basic stacking hats pattern and basic woody ennemy

This commit is contained in:
Deadzi06
2026-08-08 16:06:07 +02:00
parent d17c13f2ca
commit 0796d64a8d
8 changed files with 248 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
---@class HatBullet : Bullet
local HatBullet, super = Class(Bullet)
---@param x number # The X position of the bullet
---@param y number # The Y position of the bullet
---@param dir number # The dir (in radians) of the bullet
---@param speed number # The speed the bullet will move at in the specified direction
function HatBullet:init(x, y, dir, speed)
-- Last argument = sprite path
super.init(self, x, y, "bullets/hatbullet")
-- Move the bullet in dir radians (0 = right, pi = left, clockwise rotation)
self.physics.direction = dir
-- Speed the bullet moves (pixels per frame at 30FPS)
self.physics.speed = speed
self.collision = false
end
function HatBullet:update()
-- For more complicated bullet behaviours, code here gets called every update
super.update(self)
end
return HatBullet

View File

@@ -0,0 +1,21 @@
local Woody, super = Class(Encounter)
function Woody:init()
super.init(self)
-- Text displayed at the bottom of the screen at the start of the encounter
self.text = "* The tutorial begins...?"
-- Battle music ("battle" is rude buster)
self.music = "battle"
-- Enables the purple grid battle background
self.background = true
-- Add the woody enemy to the encounter
self:addEnemy("woody")
--- Uncomment this line to add another!
--self:addEnemy("woody")
end
return Woody

View File

@@ -0,0 +1,96 @@
local Woody, super = Class(EnemyBattler)
function Woody:init()
super.init(self)
-- Enemy name
self.name = "Woody"
-- Sets the actor, which handles the enemy's sprites (see scripts/data/actors/Woody.lua)
self:setActor("woody")
-- Enemy health
self.max_health = 450
self.health = 450
-- Enemy attack (determines bullet damage)
self.attack = 4
-- Enemy defense (usually 0)
self.defense = 0
-- Enemy reward
self.money = 100
-- Mercy given when sparing this enemy before its spareable (20% for basic enemies)
self.spare_points = 20
-- List of possible wave ids, randomly picked each turn
self.waves = {
"basic",
"aiming",
"movingarena"
}
-- Dialogue randomly displayed in the enemy's speech bubble
self.dialogue = {
"..."
}
-- Check text (automatically has "ENEMY NAME - " at the start)
self.check = "AT 4 DF 0\n* Cotton heart and button eye\n* Looks just like a fluffy guy."
-- Text randomly displayed at the bottom of the screen each turn
self.text = {
"* The Woody gives you a soft\nsmile.",
"* The power of fluffy boys is\nin the air.",
"* Smells like cardboard.",
}
-- Text displayed at the bottom of the screen when the enemy has low health
self.low_health_text = "* The Woody looks like it's\nabout to fall over."
-- Register act called "Smile"
self:registerAct("Smile")
-- Register party act with Ralsei called "Tell Story"
-- (second argument is description, usually empty)
self:registerAct("Tell Story", "", {"ralsei"})
end
function Woody:onAct(battler, name)
if name == "Smile" then
-- Give the enemy 100% mercy
self:addMercy(100)
-- Change this enemy's dialogue for 1 turn
self.dialogue_override = "... ^^"
-- Act text (since it's a list, multiple textboxes)
return {
"* You smile.[wait:5]\n* The Woody smiles back.",
"* It seems the Woody just wanted\nto see you happy."
}
elseif name == "Tell Story" then
-- Loop through all enemies
for _, enemy in ipairs(Game.battle.enemies) do
-- Make the enemy tired
enemy:setTired(true)
end
return "* You and Ralsei told the Woody\na bedtime story.\n* The enemies became [color:blue]TIRED[color:reset]..."
elseif name == "Standard" then --X-Action
-- Give the enemy 50% mercy
self:addMercy(50)
if battler.chara.id == "ralsei" then
-- R-Action text
return "* Ralsei bowed politely.\n* The Woody spiritually bowed\nin return."
elseif battler.chara.id == "susie" then
-- S-Action: start a cutscene (see scripts/battle/cutscenes/Woody.lua)
Game.battle:startActCutscene("Woody", "susie_punch")
return
else
-- Text for any other character (like Noelle)
return "* "..battler.chara:getName().." straightened the\nWoody's hat."
end
end
-- If the act is none of the above, run the base onAct function
-- (this handles the Check act)
return super.onAct(self, battler, name)
end
return Woody

View File

@@ -0,0 +1,50 @@
local StackingHats, super = Class(Wave)
function StackingHats:init()
super.init(self)
-- The duration of our wave, in seconds. (Defaults to `5`)
self.time = 10
self.count = 0
end
function StackingHats:onStart()
-- code here gets called at the start of the wave
-- create a bullet in the center of the screen
arena = Game.battle.arena
arenaX, arenaY = arena:getBottomLeft()
arenaX2, arenaY2 = arena:getBottomRight()
self.collider = LineCollider(self, arenaX, arenaY, arenaX2, arenaY2)
self.timer:everyInstant(1, function()
local x = SCREEN_WIDTH / 2
local y = arena:getTop() * 0.5
self.bullets[self.count] = self:spawnBullet("hatbulllet", x, y)
-- set the bullet's speed to 4 (pixels per 1/30th second)
self.bullets[self.count].physics.speed = 4
self.count = self.count + 1
end)
super.onStart(self)
end
function StackingHats:update()
-- code here gets called every frame
for i = 0, self.count -1, 1 do
for j = 0, i-1, 1 do
if (i ~= j) then
if (self.bullets[i].collider:collidesWith(self.bullets[j])) then
self.bullets[i].physics.speed = 0
end
end
end
if (self.bullets[i].collider:collidesWith(self)) then
self.bullets[i].physics.speed = 0
end
end
super.update(self)
end
return StackingHats