Skip to content

Commit

Permalink
[+] Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
warioddly committed Nov 22, 2023
1 parent 63f966d commit 69e3da3
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 14 deletions.
Binary file removed assets/fonts/press_start_2P.ttf
Binary file not shown.
9 changes: 4 additions & 5 deletions lib/characters/character.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ enum CharacterState {
attack2,
skill,


}

class Character<T extends FlameGame> extends SpriteAnimationComponent with HasGameReference<T>, KeyboardHandler, CollisionCallbacks {
Expand Down Expand Up @@ -139,20 +138,20 @@ class Character<T extends FlameGame> extends SpriteAnimationComponent with HasGa
}


void infinityRandomMovement() {
void infinityRandomMovement([Path? path, EffectController? controller]) {

Future.delayed(const Duration(milliseconds: 100), () {
character.current = CharacterState.running;
});

add(
MoveAlongPathEffect(
Path()
path ?? Path()
..moveTo(100, 0)
..lineTo(200, 100)
..lineTo(400, 100)
..lineTo(550, 550),
EffectController(
..lineTo(550, 500),
controller ?? EffectController(
duration: 15,
reverseDuration: 15,
infinite: true,
Expand Down
72 changes: 72 additions & 0 deletions lib/decorations/blocks/clickable_box.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import 'package:flame/collisions.dart';
import 'package:flame/components.dart';
import 'package:flame/events.dart';
import 'package:flutter/material.dart';
import 'package:warioddly/utils/configs/text.dart';


class TouchableComponent extends PositionComponent with HoverCallbacks {

TouchableComponent() : super(
);


@override
Future<void> onLoad() async {
super.onLoad();
add(
TextComponent(
text: 'Hello',
textRenderer: TextConfig.renderer,
)
);
}



@override
void onHoverEnter() {
print('122');
super.onHoverEnter();
}

}

class MyShapeComponent extends PositionComponent
with TapCallbacks, HoverCallbacks, GestureHitboxes {
final ShapeHitbox hitbox;
late final Color baseColor;
late final Color hoverColor;

MyShapeComponent({
required this.hitbox,
super.position,
super.size,
super.angle,
}) : super(anchor: Anchor.center);

@override
Future<void> onLoad() async {
super.onLoad();
baseColor = Colors.white;
hitbox.paint.color = baseColor;
hitbox.renderShape = true;
add(hitbox);
}

@override
void onTapDown(TapDownEvent _) {
removeFromParent();
}

@override
void onHoverEnter() {
print('hover');
hitbox.paint.color = hitbox.paint.color;
}

@override
void onHoverExit() {
hitbox.paint.color = baseColor;
}
}
4 changes: 3 additions & 1 deletion lib/game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class AdventureGame extends FlameGame with HasKeyboardHandlerComponents {

add(FpsTextComponent(position: Vector2(10, 10)));

camera.follow((world as MyWorld).player, maxSpeed: Universe.cameraSpeed);
camera
..viewfinder.zoom = 1.5
..follow((world as MyWorld).player, maxSpeed: Universe.cameraSpeed);

}

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/constants/universe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ class Universe {

static const size = 1000.0;
static const playerSpeed = 200.0;
static const cameraSpeed = 150.0;
static const cameraSpeed = 130.0;

}
16 changes: 11 additions & 5 deletions lib/worlds/my_world.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@
import 'dart:async';
import 'package:flame/collisions.dart';
import 'package:flame/components.dart';
import 'package:flame/events.dart';
import 'package:flame/palette.dart';
import 'package:flutter/material.dart';
import 'package:warioddly/characters/ghost.dart';
import 'package:warioddly/characters/wizard.dart';
import 'package:warioddly/decorations/blocks/clickable_box.dart';
import 'package:warioddly/decorations/texts/animated_text_box.dart';
import 'package:warioddly/game.dart';
import 'package:warioddly/utils/configs/text.dart';
import '../utils/mixins/component_light_mixin.dart';


class MyWorld extends World with HasGameRef<AdventureGame>, HasCollisionDetection, HasCharacterLighting<AdventureGame> {
class MyWorld extends World with HasGameRef<AdventureGame>, HasCollisionDetection, HasCharacterLighting<AdventureGame>, TapCallbacks {

MyWorld();


Wizard wizard = Wizard(handleKeyboardEvents: false);
Ghost player = Ghost(priority: 2, handleKeyboardEvents: true);
Ghost player = Ghost(priority: 2, handleKeyboardEvents: true)..position = Vector2(0, 0.01);


@override
Expand All @@ -43,7 +45,8 @@ I'm IMØ, and I'm passionate about web/mobile development. Here, you'll find a c
Feel free to explore and get to know more about my journey. If you have any questions or if there's something specific you're looking for, don't hesitate to reach out.
Thanks for stopping by, and I hope you enjoy your visit!"'''
Thanks for stopping by, and I hope you enjoy your visit!"''',
size: Vector2(450, 300)
)
..anchor = Anchor.center
..y = -220,
Expand Down Expand Up @@ -78,11 +81,14 @@ Thanks for stopping by, and I hope you enjoy your visit!"'''
children: [RectangleHitbox()],
),

TouchableComponent(),
MyShapeComponent(hitbox: CircleHitbox()),
]);


addLight(player, player.lightConfig);
addLight(wizard, wizard.lightConfig);

// addLight(player, player.lightConfig);
// addLight(wizard, wizard.lightConfig);

wizard
..add(TextBoxComponent(
Expand Down
3 changes: 1 addition & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ flutter:
# list giving the asset and other descriptors for the font. For
# example:
fonts:
- family: PressStart2P
- family: VT323
fonts:
- asset: assets/fonts/press_start_2P.ttf
- asset: assets/fonts/VT323-Regular.ttf
# - family: Trajan Pro
# fonts:
Expand Down

0 comments on commit 69e3da3

Please sign in to comment.