Akció animációk
This commit is contained in:
@@ -39,12 +39,13 @@ class StatusChange:
|
|||||||
|
|
||||||
# where = reference to the target, who = reference to the inflictor
|
# where = reference to the target, who = reference to the inflictor
|
||||||
class Action:
|
class Action:
|
||||||
def __init__(self, name, who, where, damage, status):
|
def __init__(self, name, who, where, damage, status, animation):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.who = who
|
self.who = who
|
||||||
self.where = where
|
self.where = where
|
||||||
self.damage = damage
|
self.damage = damage
|
||||||
self.status = status
|
self.status = status
|
||||||
|
self.animation = animation
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return (
|
return (
|
||||||
@@ -113,4 +114,4 @@ class Action:
|
|||||||
target.ko = True
|
target.ko = True
|
||||||
target.stone = False
|
target.stone = False
|
||||||
target.def_up = False
|
target.def_up = False
|
||||||
print(f" -> {target.name} got hurt and collapsed!")
|
print(f" -> {target.name} got hurt and collapsed!")
|
||||||
|
|||||||
@@ -1,32 +1,44 @@
|
|||||||
import random
|
import random
|
||||||
from battle import Combatant, Action, Damage, StatusChange
|
from battle import Combatant, Action, Damage, StatusChange
|
||||||
|
|
||||||
|
def anim_default(action, text, timer, dt):
|
||||||
|
if timer == 0:
|
||||||
|
text.reset(action.name)
|
||||||
|
text.type_all()
|
||||||
|
|
||||||
|
if timer >= 1:
|
||||||
|
text.reset("")
|
||||||
|
action.execute()
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def move_attack(user, target):
|
def move_attack(user, target):
|
||||||
return Action("Attack", user, target, Damage(user.attack, 0, 0, 0), StatusChange(0, 0, 0))
|
return Action("Attack", user, target, Damage(user.attack, 0, 0, 0), StatusChange(0, 0, 0), anim_default)
|
||||||
|
|
||||||
def move_fire(user, target):
|
def move_fire(user, target):
|
||||||
return Action("Fira", user, target, Damage(0, 45, 0, 0), StatusChange(0, 0, 0))
|
return Action("Fira", user, target, Damage(0, 45, 0, 0), StatusChange(0, 0, 0), anim_default)
|
||||||
|
|
||||||
def move_ice(user, target):
|
def move_ice(user, target):
|
||||||
return Action("Blizzara", user, target, Damage(0, 0, 45, 0), StatusChange(0, 0, 0))
|
return Action("Blizzara", user, target, Damage(0, 0, 45, 0), StatusChange(0, 0, 0), anim_default)
|
||||||
|
|
||||||
def move_cure(user, target):
|
def move_cure(user, target):
|
||||||
return Action("Cure", user, target, Damage(0, 0, 0, 42), StatusChange(0, 0, 0))
|
return Action("Cure", user, target, Damage(0, 0, 0, 42), StatusChange(0, 0, 0), anim_default)
|
||||||
|
|
||||||
def move_defend(user, target):
|
def move_defend(user, target):
|
||||||
return Action("Defend", user, target, Damage(0, 0, 0, 0), StatusChange(0, 0, 1))
|
return Action("Defend", user, target, Damage(0, 0, 0, 0), StatusChange(0, 0, 1), anim_default)
|
||||||
|
|
||||||
def move_break(user, target):
|
def move_break(user, target):
|
||||||
return Action("Break", user, target, Damage(0, 0, 0, 0), StatusChange(0, 1, 0))
|
return Action("Break", user, target, Damage(0, 0, 0, 0), StatusChange(0, 1, 0), anim_default)
|
||||||
|
|
||||||
def move_death(user, target):
|
def move_death(user, target):
|
||||||
return Action("Death", user, target, Damage(0, 0, 0, 0), StatusChange(1, 0, 0))
|
return Action("Death", user, target, Damage(0, 0, 0, 0), StatusChange(1, 0, 0), anim_default)
|
||||||
|
|
||||||
def move_phoenix(user, target):
|
def move_phoenix(user, target):
|
||||||
return Action("Phoenix Down", user, target, Damage(0, 0, 0, 30), StatusChange(2, 0, 0))
|
return Action("Phoenix Down", user, target, Damage(0, 0, 0, 30), StatusChange(2, 0, 0), anim_default)
|
||||||
|
|
||||||
def move_softenup(user, target):
|
def move_softenup(user, target):
|
||||||
return Action("Esuna", user, target, Damage(0, 0, 0, 0), StatusChange(2, 0, 0))
|
return Action("Esuna", user, target, Damage(0, 0, 0, 0), StatusChange(2, 0, 0), anim_default)
|
||||||
|
|
||||||
def enemy_turn_test(e,ep, ap,d):
|
def enemy_turn_test(e,ep, ap,d):
|
||||||
living = [p for p in ap if not p.ko]
|
living = [p for p in ap if not p.ko]
|
||||||
@@ -136,4 +148,4 @@ battles = [
|
|||||||
["Phoenix Down",67, ("Phoenix Down", move_phoenix, False)]
|
["Phoenix Down",67, ("Phoenix Down", move_phoenix, False)]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -13,16 +13,19 @@ enemies = []
|
|||||||
party_members = []
|
party_members = []
|
||||||
enemy_turn = None
|
enemy_turn = None
|
||||||
battle_music = None
|
battle_music = None
|
||||||
|
enemy_ai_data = {}
|
||||||
party_menus = []
|
party_menus = []
|
||||||
spells = []
|
spells = []
|
||||||
inventory = []
|
inventory = []
|
||||||
|
|
||||||
action_queue = []
|
action_queue = []
|
||||||
enemy_ai_data = {}
|
cur_action = None
|
||||||
|
action_timer = 0
|
||||||
|
|
||||||
party_text = TextRenderer(3, 206, 210)
|
party_text = TextRenderer(3, 206, 210)
|
||||||
ene_text = TextRenderer(123, 206, 210)
|
ene_text = TextRenderer(123, 206, 210)
|
||||||
menu_text = TextRenderer(3, 76, 210)
|
menu_text = TextRenderer(3, 76, 210)
|
||||||
|
action_text = TextRenderer(110, 215, 210)
|
||||||
|
|
||||||
menu_open = 0
|
menu_open = 0
|
||||||
menu_queue = []
|
menu_queue = []
|
||||||
@@ -54,14 +57,14 @@ def menu_action(data):
|
|||||||
case "unselectable":
|
case "unselectable":
|
||||||
return
|
return
|
||||||
case "phys_att":
|
case "phys_att":
|
||||||
action_queue.append(Action("Physical Attack", user, eparty[0], Damage(166, 0, 0, 0), StatusChange(0, 0, 0)))
|
action_queue.append(Action("Physical Attack", user, eparty[0], Damage(166, 0, 0, 0), StatusChange(0, 0, 0), battle_data.anim_default))
|
||||||
close_menu()
|
close_menu()
|
||||||
case _:
|
case _:
|
||||||
print(f"Unknown action: {action}")
|
print(f"Unknown action: {action}")
|
||||||
close_menu()
|
close_menu()
|
||||||
|
|
||||||
def update(game, dt):
|
def update(game, dt):
|
||||||
global menu_open
|
global menu_open, cur_action, action_timer
|
||||||
|
|
||||||
for e in enemies:
|
for e in enemies:
|
||||||
if e.ko or e.stone:
|
if e.ko or e.stone:
|
||||||
@@ -82,11 +85,19 @@ def update(game, dt):
|
|||||||
menu_queue.append(p)
|
menu_queue.append(p)
|
||||||
p.atb = math.inf
|
p.atb = math.inf
|
||||||
|
|
||||||
if len(action_queue) != 0:
|
if len(action_queue) != 0 and cur_action == None:
|
||||||
action = action_queue.pop(0)
|
action = action_queue.pop(0)
|
||||||
print(f"Executing: {action}")
|
print(f"Executing: {action}")
|
||||||
action.execute()
|
cur_action = action
|
||||||
|
action_timer = 0
|
||||||
|
|
||||||
|
if cur_action != None:
|
||||||
|
if cur_action.animation(cur_action, action_text, action_timer, dt):
|
||||||
|
cur_action = None
|
||||||
|
else:
|
||||||
|
action_timer += dt
|
||||||
|
|
||||||
|
|
||||||
# Szövegek Frissítése
|
# Szövegek Frissítése
|
||||||
partytext = ""
|
partytext = ""
|
||||||
enetext = ""
|
enetext = ""
|
||||||
@@ -128,4 +139,5 @@ def draw(game):
|
|||||||
party_text.render()
|
party_text.render()
|
||||||
ene_text.render()
|
ene_text.render()
|
||||||
menu_text.render()
|
menu_text.render()
|
||||||
|
action_text.render()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user