-
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.
feat: Implementa Wife Mom and Wife Father on lvl 01
- Loading branch information
1 parent
f893cc1
commit 30b0e41
Showing
12 changed files
with
154 additions
and
17 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,20 @@ | ||
import 'dart:ui'; | ||
|
||
import 'package:flame/components.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class CharacterShadow extends PositionComponent { | ||
@override | ||
void render(Canvas canvas) { | ||
// Draw an ellipse for the shadow | ||
final paint = Paint()..color = Colors.black.withOpacity(0.5); | ||
canvas.drawOval( | ||
Rect.fromCenter( | ||
center: Offset(size.x / 2, size.y), | ||
width: size.x * 0.8, | ||
height: size.y * 0.2, | ||
), | ||
paint, | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,26 +1,77 @@ | ||
import 'dart:math'; | ||
import 'dart:ui'; | ||
|
||
import 'package:moonshiner_game/components/CharacterShadow.dart'; | ||
import 'package:moonshiner_game/components/npc.dart'; | ||
import 'package:flame/components.dart'; | ||
import 'package:moonshiner_game/components/utils.dart'; | ||
|
||
class WifesMom extends AbstractNPC { | ||
WifesMom({required Vector2 position}) | ||
: super( | ||
npcCharacter: 'Wifes Mother', | ||
npcCharacter: 'Wife\'s Mother', | ||
dialogues: [ | ||
"Farewell, my dear daughter!", | ||
"Please take care of yourself and your husband.", | ||
], | ||
position: position, | ||
); | ||
|
||
@override | ||
Future<void> onLoad() async { | ||
loadAllAnimations(); | ||
|
||
// Create a shadow component | ||
final shadow = CharacterShadow() | ||
..size = Vector2(16, 4) // Adjust size based on your character | ||
..position = | ||
Vector2(8, size.y - 4); // Position the shadow below the character | ||
|
||
// Add the shadow as a child | ||
add(shadow); | ||
return super.onLoad(); | ||
} | ||
|
||
@override | ||
Color getColorForNPC() => const Color(0xFFFFAAAA); // Light pink for the mom | ||
|
||
@override | ||
void updateMovement(double dt) { | ||
// This NPC does not move, so velocity is always zero | ||
void loadAllAnimations() { | ||
final idleAnimation = spriteAnimation('Idle', 11); | ||
final walkingAnimation = spriteAnimation('Run', 11); | ||
|
||
animations = { | ||
NPCState.idle: idleAnimation, | ||
NPCState.walking: walkingAnimation, | ||
}; | ||
current = NPCState.idle; | ||
velocity = Vector2.zero(); | ||
} | ||
|
||
@override | ||
SpriteAnimation spriteAnimation(String state, int amount) { | ||
return SpriteAnimation.fromFrameData( | ||
game.images.fromCache('Main Characters/Wife Mom/$state (32x32).png'), | ||
SpriteAnimationData.sequenced( | ||
amount: amount, | ||
stepTime: 0.05, | ||
textureSize: Vector2.all(32), | ||
), | ||
); | ||
} | ||
|
||
@override | ||
void update(double dt) { | ||
checkCollisions(); | ||
|
||
velocity = Vector2.all(0); | ||
|
||
super.update(dt); | ||
} | ||
|
||
@override | ||
void checkCollisions() {} | ||
|
||
@override | ||
void updateMovement(double dt) { | ||
// TODO: implement updateMovement | ||
} | ||
} |
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
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