Skip to content

Commit

Permalink
controller sounds, music tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
chosencharacters committed Dec 4, 2024
1 parent af09066 commit 99e024e
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<!-- _________________________ Application Settings _________________________ -->

<app title="Tankmas 2024" file="Tankmas 2024" main="Main" version="3.0.0" company="Glenside Helper Elf Society" />
<app title="Tankmas 2024" file="Tankmas 2024" main="Main" version="3.0.1" company="Glenside Helper Elf Society" />

<!--The flixel preloader is not accurate in Chrome. You can use it regularly if you embed the swf into a html file
or you can set the actual size of your file manually at "FlxPreloaderBase-onUpdate-bytesTotal"-->
Expand Down
Binary file added assets/sounds/fx/controller-1.ogg
Binary file not shown.
Binary file added assets/sounds/fx/controller-2.ogg
Binary file not shown.
Binary file added assets/sounds/fx/controller-3.ogg
Binary file not shown.
Binary file added assets/sounds/fx/controller-4.ogg
Binary file not shown.
3 changes: 3 additions & 0 deletions source/SoundPlayer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ class SoundPlayer
public static function music(music_asset:String, vol:Float = 1)
{
music_asset = music_asset.replace(".ogg", "");
trace(MUSIC_VOLUME);
FlxG.sound.playMusic(Paths.get('${music_asset}.ogg'), MUSIC_VOLUME * vol);
FlxG.sound.music.persist = true;
trace(FlxG.sound.music);
return FlxG.sound.music;
}

Expand Down
21 changes: 21 additions & 0 deletions source/entities/Player.hx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class Player extends BaseUser
var auto_move_dest:FlxPoint;
final auto_move_deadzone:Int = 32;

var wavedash_cd:Int = 0;

var prev_velocity:FlxPoint = new FlxPoint();

public function new(?X:Float, ?Y:Float)
{
super(X, Y, Main.username);
Expand Down Expand Up @@ -90,10 +94,27 @@ class Player extends BaseUser
/**if (Main.DEV && Ctrl.any(Ctrl.menu))
debug_rotate_costumes();**/

if (wavedash_cd > 0)
wavedash_cd--;

fsm();
super.update(elapsed);
}

override function updateMotion(elapsed:Float)
{
if (prev_velocity.x > 0 && velocity.x < 0 || prev_velocity.x < 0 && velocity.x > 0)
{
if (wavedash_cd < 300)
wavedash_cd += 35;
if (wavedash_cd >= 150)
SoundPlayer.alt_sound("controller", true, ["controller-1", "controller-2", "controller-3", "controller-4"]);
}
prev_velocity.copyFrom(velocity);

super.updateMotion(elapsed);
}

function fsm()
switch (cast(state, State))
{
Expand Down
2 changes: 1 addition & 1 deletion source/states/BaseState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BaseState extends FlxState
#if !no_radio
radio = new RadioManager();
#else
SoundPlayer.music('christmasjoy-realtin3sn.ogg');
SoundPlayer.music('christmasjoy-realtin3sn');
#end

#if !no_fade
Expand Down
4 changes: 2 additions & 2 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package states;

import net.tankmas.NetDefs.NetEventType;
import net.tankmas.NetDefs.NetEventDef;
import activities.ActivityArea;
import data.SaveManager;
import entities.Interactable;
Expand All @@ -16,6 +14,8 @@ import fx.StickerFX;
import fx.Thumbnail;
import levels.TankmasLevel;
import minigames.MinigameHandler;
import net.tankmas.NetDefs.NetEventDef;
import net.tankmas.NetDefs.NetEventType;
import net.tankmas.NetDefs.NetUserDef;
import net.tankmas.OnlineLoop;
import net.tankmas.TankmasClient;
Expand Down

0 comments on commit 99e024e

Please sign in to comment.