-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from uspgamedev/dev
v0.2
- Loading branch information
Showing
55 changed files
with
1,879 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.vscode/ | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
local AI = Component.create("AI") | ||
|
||
function AI:initialize(goals, actions) | ||
self.goals = goals | ||
self.actions = actions | ||
self.currentState = {} | ||
self.currentAction = nil | ||
end | ||
|
||
function AI:getAction(effect) | ||
for _, action in pairs(self.actions) do | ||
for _, e in pairs(action.effects) do | ||
if (e.name == effect.name and e.target == effect.target) then | ||
return action | ||
end | ||
end | ||
end | ||
return nil | ||
end | ||
|
||
function AI:getActions(effect) | ||
local result = {} | ||
for _, action in pairs(self.actions) do | ||
for _, e in pairs(action.effects) do | ||
if (e.name == effect.name and e.target == effect.target) then | ||
table.insert(result, action) | ||
end | ||
end | ||
end | ||
return result | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
local AttackProperties = Component.create("AttackProperties") | ||
|
||
function AttackProperties:initialize(damage, spawnDistance) | ||
self.damage = damage | ||
function AttackProperties:initialize(spawnDistance) | ||
self.spawnDistance = spawnDistance | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
local AttackRange = Component.create("AttackRange") | ||
|
||
function AttackRange:initialize(max, min) | ||
self.max = max | ||
self.min = min or -1 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
local Damage = Component.create("Damage") | ||
|
||
function Damage:initialize(damage) | ||
self.damage = damage | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
local Follow = Component.create("Follow") | ||
|
||
-- target must be an entity with Position component | ||
function Follow:initialize(target) | ||
self.target = target | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
local Label = Component.create("Label") | ||
|
||
function Label:initialize(label) | ||
self.label = label | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
local Stats = Component.create("Stats") | ||
|
||
function Stats:initialize(damage, movement_speed, shot_speed, bullet_speed, shot_range) | ||
self.damage = damage | ||
self.movement_speed = movement_speed | ||
self.shot_speed = shot_speed | ||
self.bullet_speed = bullet_speed | ||
self.shot_range = shot_range | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
local Visibility = Component.create("Visibility") | ||
|
||
function Visibility:initialize(visible) | ||
self.visible = visible | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
local Label, Timer, AttackProperties, Damage, AttackRange | ||
= Component.load({"Label", "Timer", "AttackProperties", "Damage", "AttackRange"}) | ||
|
||
function createPlayerAttack(parent) | ||
local entity = Entity(parent) | ||
entity:add(Label("RangedAttack")) | ||
entity:add(Timer(0.3)) | ||
entity:add(AttackProperties(25)) | ||
entity:add(Damage(5)) | ||
entity:add(AttackRange(250)) | ||
return entity | ||
end | ||
|
||
function createMeleeAttack(parent) | ||
local entity = Entity(parent) | ||
entity:add(Label("MeleeAttack")) | ||
entity:add(Timer(1)) | ||
entity:add(AttackProperties(0)) | ||
entity:add(Damage(2)) | ||
entity:add(AttackRange(2)) | ||
return entity | ||
end | ||
|
||
function createRangedAttack(parent) | ||
local entity = Entity(parent) | ||
entity:add(Label("RangedAttack")) | ||
entity:add(Timer(0.5)) | ||
entity:add(AttackProperties(25)) | ||
entity:add(Damage(1)) | ||
entity:add(AttackRange(400)) | ||
return entity | ||
end | ||
|
||
function createDashAttack(parent) | ||
local entity = Entity(parent) | ||
entity:add(Label("DashAttack")) | ||
entity:add(Timer(2)) | ||
entity:add(AttackProperties(8)) | ||
entity:add(Damage(1)) | ||
entity:add(AttackRange(200)) | ||
return entity | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,26 @@ | ||
local Position, Circle, Velocity, Projectile, Color, Collider | ||
= Component.load({"Position", "Circle", "Velocity", "Projectile", "Color", "Collider"}) | ||
|
||
function createBullet(x, y, direction, damage) | ||
local entity = Entity() | ||
function createBullet(entity, x, y, direction, damage) | ||
entity:add(Position(x, y)) | ||
entity:add(Circle(5)) | ||
entity:add(Velocity(direction.x, direction.y, 1000)) | ||
entity:add(Projectile(damage, distToPix(7))) | ||
end | ||
|
||
function createPlayerBullet(x, y, direction, damage, range) | ||
local entity = Entity() | ||
entity:add(Color(255, 255, 255)) | ||
entity:add(Collider("Bullet", true)) | ||
createBullet(entity, x, y, direction, damage) | ||
entity:add(Projectile("Player", damage, range)) | ||
entity:add(Collider("PlayerBullet", true)) | ||
return entity | ||
end | ||
|
||
function createEnemyBullet (parent, x, y, direction, damage, range) | ||
local entity = Entity(parent) | ||
entity:add(Color(255, 255, 0)) | ||
createBullet(entity, x, y, direction, damage) | ||
entity:add(Projectile("Enemy", damage, range)) | ||
entity:add(Collider("EnemyBullet", false)) | ||
return entity | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
local Position, Circle, Color, Collider, Damage, Follow = | ||
Component.load({"Position", "Circle", "Color", "Collider", "Damage", "Follow"}) | ||
|
||
function createDamageArea(position, radius, damage, parent, followParent) | ||
local entity = Entity(parent) | ||
entity:add(Position(position.x, position.y)) | ||
entity:add(Color(255, 0, 0)) | ||
entity:add(Circle(radius)) | ||
entity:add(Damage(damage)) | ||
entity:add(Collider("DamageArea", true)) | ||
if(followParent) then | ||
entity:add(Follow(parent)) | ||
end | ||
return entity | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,68 @@ | ||
local Position, Circle, IsEnemy, Velocity, Color, Collider, Timer = | ||
Component.load({"Position", "Circle", "IsEnemy", "Velocity", "Color", "Collider", "Timer"}) | ||
local Position, | ||
Circle, | ||
AI, | ||
Velocity, | ||
Color, | ||
Collider, | ||
Timer = Component.load({"Position", "Circle", "AI", "Velocity", "Color", "Collider", "Timer"}) | ||
|
||
function createEnemy(x, y) | ||
local Actions = require "systems/ai/Actions" | ||
|
||
function createDumbEnemy(x, y) | ||
local entity = Entity() | ||
entity:add(Position(x, y)) | ||
entity:add(Circle(20)) | ||
entity:add(Velocity(0, 0, 200)) | ||
entity:add(IsEnemy("FollowPlayer", "Melee")) | ||
entity:add(Color(0, 255, 255)) | ||
entity:add(Collider("Enemy", true)) | ||
entity:add(Timer(0.5)) | ||
return entity | ||
end | ||
|
||
function createDashEnemy(x, y) | ||
local entity = Entity() | ||
entity:add(Position(x, y)) | ||
entity:add(Circle(20)) | ||
entity:add(Velocity(0, 0, 200)) | ||
entity:add(AI({name = "Damage"}, {Actions.MeleeAttack, Actions.DashAttack, Actions.FollowPlayer})) | ||
entity:add(Color(0, 255, 255)) | ||
entity:add(Collider("Enemy", true)) | ||
entity:add(Timer(0.5)) | ||
return entity | ||
end | ||
|
||
function createMeleeEnemy(x, y) | ||
local entity = Entity() | ||
entity:add(Position(x, y)) | ||
entity:add(Circle(20)) | ||
entity:add(Velocity(0, 0, 200)) | ||
entity:add(AI({name = "Damage"}, {Actions.MeleeAttack, Actions.FollowPlayer})) | ||
entity:add(Color(255, 0, 255)) | ||
entity:add(Collider("Enemy", true)) | ||
entity:add(Timer(0.5)) | ||
return entity | ||
end | ||
|
||
function createRangedEnemy(x, y) | ||
local entity = Entity() | ||
entity:add(Position(x, y)) | ||
entity:add(Circle(20)) | ||
entity:add(Velocity(0, 0, 200)) | ||
entity:add(AI({name = "Damage"}, {Actions.RangedAttack, Actions.FleeFromPlayer, Actions.FollowPlayer})) | ||
entity:add(Color(255, 255, 0)) | ||
entity:add(Collider("Enemy", true)) | ||
entity:add(Timer(0.5)) | ||
return entity | ||
end | ||
|
||
function createHybridEnemy(x, y) | ||
local entity = Entity() | ||
entity:add(Position(x, y)) | ||
entity:add(Circle(20)) | ||
entity:add(Velocity(0, 0, 200)) | ||
entity:add(AI({name = "Damage"}, {Actions.RangedAttack, Actions.FollowPlayer, Actions.MeleeAttack, Actions.FleeFromPlayer, Actions.DashAttack})) | ||
entity:add(Color(255, 255, 127)) | ||
entity:add(Collider("Enemy", true)) | ||
entity:add(Timer(0.5)) | ||
return entity | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
local Timer, Label = Component.load({"Timer", "Label"}) | ||
|
||
function createInvunerable(parent) | ||
local entity = Entity(parent) | ||
entity:add(Timer(1)) | ||
entity:add(Label("Invunerable")) | ||
return entity | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
local Position, Circle, IsPlayer, Velocity, AttackProperties, Timer, HP, Color, Collider = | ||
Component.load({"Position", "Circle", "IsPlayer", "Velocity", "AttackProperties", "Timer", "Hitpoints", "Color", "Collider"}) | ||
local Position, Circle, IsPlayer, Velocity, AttackProperties, Timer, HP, Color, Collider, Stats = | ||
Component.load({"Position", "Circle", "IsPlayer", "Velocity", "AttackProperties", "Timer", "Hitpoints", "Color", "Collider", "Stats"}) | ||
|
||
function createPlayer(x, y) | ||
local entity = Entity() | ||
entity:add(Position(x, y)) | ||
entity:add(Circle(20)) | ||
entity:add(Velocity(0, 0, 500)) | ||
entity:add(AttackProperties(5, 25)) | ||
entity:add(HP(20)) | ||
entity:add(Timer(0.3)) | ||
entity:add(IsPlayer()) | ||
entity:add(Color(255, 255, 255)) | ||
entity:add(Collider("Player", true)) | ||
entity:add(Stats(2, 10, 20, 10, 10)) | ||
return entity | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
local Stats = Component.load({"Stats"}) | ||
|
||
function createStatsUpgrade(damage, movement_speed, shot_speed, bullet_speed, shot_range, duration) | ||
local entity = Entity() | ||
entity:add(Stats(damage, movement_speed, shot_speed, bullet_speed, shot_range)) | ||
entity:add(Timer(duration)) | ||
return entity | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
local Label, Position, Circle, Color, Collider, Visibility = | ||
Component.load({"Label", "Position", "Circle", "Color", "Collider", "Visibility" }) | ||
|
||
function createDamageTrap(x, y) | ||
local entity = Entity() | ||
entity:add(Label("DamageTrap")) | ||
entity:add(Position(x, y)) | ||
entity:add(Circle(10)) | ||
entity:add(Color(100, 15, 15)) | ||
entity:add(Collider("Trap", true)) | ||
entity:add(Visibility(true)) | ||
return entity | ||
end | ||
|
||
function createPushTrap(x, y) | ||
local entity = Entity() | ||
entity:add(Label("PushTrap")) | ||
entity:add(Position(x, y)) | ||
entity:add(Circle(10)) | ||
entity:add(Color(15, 15, 100)) | ||
entity:add(Collider("Trap", true)) | ||
entity:add(Visibility(true)) | ||
return entity | ||
end | ||
|
||
function createHealingTrap(x, y) | ||
local entity = Entity() | ||
entity:add(Label("HealingTrap")) | ||
entity:add(Position(x, y)) | ||
entity:add(Circle(10)) | ||
entity:add(Color(15, 100, 15)) | ||
entity:add(Collider("Trap", true)) | ||
entity:add(Visibility(false)) | ||
return entity | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
local actionsController = {} | ||
|
||
local Actions = require "systems/ai/Actions" | ||
|
||
function actionsController.addEffect(effects, action, effect) | ||
for i, e in ipairs(effects) do | ||
if effect.name == e.name and effect.target == e.target then | ||
e.actions[action] = 0 | ||
e.size = e.size + 1 | ||
return | ||
end | ||
end | ||
effect.actions = {} | ||
effect.actions[action] = 0 | ||
effect.size = 1 | ||
table.insert(effects, effect) | ||
end | ||
|
||
-- creates a list of effects and actions with such effects | ||
-- example: {{name=Damage, actions={Dash: 0, Ranged: 0, Melee: 0}}, ...} | ||
function actionsController.getEffects() | ||
local effects = {} | ||
for action, v in pairs(Actions) do | ||
for _, effect in pairs(v.effects) do | ||
ActionsController.addEffect(effects, action, effect) | ||
end | ||
end | ||
return effects | ||
end | ||
|
||
return actionsController |
Oops, something went wrong.