I’m excited to share something special with you today from my upcoming adventure game project that features SAME-001. While I’m keeping the full game under wraps for now (stay tuned!), I wanted to give back to the developer community by sharing the code and design process for one of our characters: SAME-001, an Egyptian-inspired warrior with mystical combat abilities.
Key design elements included:
- Egyptian-inspired headdress with gold and navy blue colors
- Mystical staff with golden ornaments
- Flowing navy blue combat dress with gold trim
- Dynamic pose structure emphasizing agility and power
Open Source Code
data class Position(val x: Float, val y: Float)
data class AnimationState(val currentFrame: Int, val totalFrames: Int)
class Same001(
private var position: Position = Position(0f, 0f),
private var health: Int = 120,
private var mana: Int = 100,
private var isChanneling: Boolean = false
) {
// Core stats
private val baseAttackDamage = 30
private val baseMagicDamage = 45
private val baseDefense = 20
private val movementSpeed = 4.5f
// Special states
private var currentAnimationState = AnimationState(0, 12)
private var isAttacking = false
private var magicShieldActive = false
// Combat mechanics
fun castMagicAttack(): Int {
if (!isChanneling && mana >= 25) {
isAttacking = true
mana -= 25
return baseMagicDamage
}
return 0
}
fun staffStrike(): Int {
if (!isChanneling && mana >= 15) {
isAttacking = true
mana -= 15
return baseAttackDamage
}
return 0
}
fun activateMagicShield() {
if (mana >= 30) {
magicShieldActive = true
isChanneling = true
mana -= 30
}
}
// Movement and positioning
fun move(dx: Float, dy: Float) {
if (!isChanneling) {
position = Position(
position.x + dx * movementSpeed,
position.y + dy * movementSpeed
)
}
}
// Damage handling
fun takeDamage(damage: Int): Int {
val actualDamage = when {
magicShieldActive -> damage / 3
isChanneling -> damage / 2
else -> damage
}
health -= actualDamage.coerceAtLeast(0)
return actualDamage
}
// Resource management
fun regenerateMana() {
if (!isAttacking && mana < 100) {
mana += 5
}
}
// State management
fun updateState() {
if (isChanneling && mana <= 0) {
isChanneling = false
magicShieldActive = false
}
}
// Animation system
fun updateAnimation() {
currentAnimationState = AnimationState(
(currentAnimationState.currentFrame + 1) % currentAnimationState.totalFrames,
currentAnimationState.totalFrames
)
}
// Getters
fun getHealth() = health
fun getMana() = mana
fun getPosition() = position
fun isChanneling() = isChanneling
fun isMagicShieldActive() = magicShieldActive
}
Key Character Features:
- Enhanced Magical Combat System:
- Implements a dual combat system combining staff strikes and magical attacks.
- Features a mana-based resource system for special abilities.
- Includes a unique magic shield mechanism for defense.
- Core Combat Attributes:
- Base health pool of 120 points for increased survivability.
- Mana pool of 100 points for sustained magical combat.
- Balanced movement speed of 4.5 units for tactical positioning.
- Defensive capability of 20 points for physical resistance.
- Special Abilities:
- Magic Shield reduces incoming damage by 66% when active.
- Channeling state provides 50% damage reduction.
- Staff Strike costs 15 mana and deals physical damage.
- Magic Attack costs 25 mana and deals enhanced magical damage.
- Technical Implementation Details:
- Position system uses floating-point precision for smooth movement.
- Animation framework supports 12 frames per animation sequence.
- Resource regeneration system for mana recovery.
- State management system for tracking active effects.
- Combat Mechanics:
- Damage calculation includes multiple defensive states.
- Movement restrictions during channeling phases.
- Automatic mana regeneration when not attacking.
- Dynamic animation state updates.
- Code Architecture:
- Modular design for easy integration into game systems.
- Clear separation of movement, combat, and state management.
- Efficient resource management system.
- Comprehensive state tracking for animations and effects.
- Performance Considerations:
- Optimized damage calculations for minimal overhead.
- Efficient position updates using data classes.
- Streamlined animation state management.
- Minimal memory footprint for core attributes.
- Balancing Features:
- Mana costs balanced against ability impact.
- Movement speed tuned for tactical gameplay.
- Defensive options require resource management.
- Regeneration rates designed for sustained combat.