diff --git a/Sprite-0002.aseprite b/Sprite-0002.aseprite index cfedf8e..d85f5b4 100644 Binary files a/Sprite-0002.aseprite and b/Sprite-0002.aseprite differ diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..e3dc686 --- /dev/null +++ b/TODO.md @@ -0,0 +1,6 @@ +x Makefile for building assets +x On/Off switch +- README file +- Pickup sprites +- Battery usage +x Brightmaps diff --git a/gldefs.txt b/gldefs.txt new file mode 100644 index 0000000..c0f247c --- /dev/null +++ b/gldefs.txt @@ -0,0 +1,24 @@ +brightmap sprite kgcma0 +{ + map "sprites/bright_kgcma0.png" + disablefullbright +} + +brightmap sprite kgcmb0 +{ + map "sprites/bright_kgcmb0.png" + disablefullbright +} + +brightmap sprite kgcna0 +{ + map "sprites/bright_kgcma0.png" + disablefullbright +} + +brightmap sprite kgcnb0 +{ + map "sprites/bright_kgcmb0.png" + disablefullbright +} + diff --git a/sounds/kirigretchencounter_click.ogg b/sounds/kirigretchencounter_click.ogg index 049ca4d..b5cff5a 100644 Binary files a/sounds/kirigretchencounter_click.ogg and b/sounds/kirigretchencounter_click.ogg differ diff --git a/source_data/Makefile b/source_data/Makefile new file mode 100644 index 0000000..841a042 --- /dev/null +++ b/source_data/Makefile @@ -0,0 +1,55 @@ +all : \ + ../sprites/kgcmb0.png \ + ../sprites/kgcma0.png \ + ../sprites/kgcna0.png \ + ../sprites/kgcnb0.png \ + ../sprites/bright_kgcma0.png \ + ../sprites/bright_kgcmb0.png \ + ../sounds/kirigretchencounter_click.ogg \ + ../sounds/kirigretchencounter_blip.ogg + +# Base frames +../sprites/kgcma0.png : gretchencounter_weaponsprite.aseprite + aseprite $^ \ + -b \ + --ignore-layer "brightmap" \ + --frame-range 0,0 --save-as $@ + +../sprites/kgcmb0.png : gretchencounter_weaponsprite.aseprite + aseprite $^ \ + -b \ + --ignore-layer "brightmap" \ + --frame-range 1,1 --save-as $@ + +# Brightmaps +../sprites/bright_kgcma0.png : gretchencounter_weaponsprite.aseprite + aseprite $^ \ + -b \ + --layer "brightmap" \ + --frame-range 0,0 --save-as $@ + +../sprites/bright_kgcmb0.png : gretchencounter_weaponsprite.aseprite + aseprite $^ \ + -b \ + --layer "brightmap" \ + --frame-range 1,1 --save-as $@ + +# Needle +../sprites/kgcna0.png : gretchencounter_weaponsprite.aseprite + aseprite $^ \ + -b \ + --layer "needle" \ + --frame-range 0,0 --save-as $@ + +../sprites/kgcnb0.png : gretchencounter_weaponsprite.aseprite + aseprite $^ \ + -b \ + --layer "needle" \ + --frame-range 1,1 --save-as $@ + +# Sounds +../sounds/kirigretchencounter_click.ogg : kirigretchencounter_click.wav + ffmpeg -i $^ "-filter:a" "volume=1.0" $@ + +../sounds/kirigretchencounter_blip.ogg : kirigretchencounter_blip.wav + ffmpeg -i $^ "-filter:a" "volume=1.0" $@ diff --git a/source_data/gretchencounter_weaponsprite.aseprite b/source_data/gretchencounter_weaponsprite.aseprite new file mode 100644 index 0000000..2bfebaa Binary files /dev/null and b/source_data/gretchencounter_weaponsprite.aseprite differ diff --git a/sprites/bright_kgcma0.png b/sprites/bright_kgcma0.png new file mode 100644 index 0000000..ea27c66 Binary files /dev/null and b/sprites/bright_kgcma0.png differ diff --git a/sprites/bright_kgcmb0.png b/sprites/bright_kgcmb0.png new file mode 100644 index 0000000..698b0f3 Binary files /dev/null and b/sprites/bright_kgcmb0.png differ diff --git a/sprites/kgcma0.png b/sprites/kgcma0.png index d4833c0..a3f26e9 100644 Binary files a/sprites/kgcma0.png and b/sprites/kgcma0.png differ diff --git a/sprites/kgcmb0.png b/sprites/kgcmb0.png new file mode 100644 index 0000000..a0a837a Binary files /dev/null and b/sprites/kgcmb0.png differ diff --git a/sprites/kgcnb0.png b/sprites/kgcnb0.png new file mode 100644 index 0000000..319e80a Binary files /dev/null and b/sprites/kgcnb0.png differ diff --git a/zscript.zs b/zscript.zs index 00eede0..45b6810 100644 --- a/zscript.zs +++ b/zscript.zs @@ -28,6 +28,7 @@ class GretchenCounter : HDWeapon float angularVelocity; float needlePosition; int framesSinceLastBeep; + bool onSwitch; override double WeaponBulk() { @@ -52,40 +53,94 @@ class GretchenCounter : HDWeapon // Needle overlay states. needle_indicator: - KGCN A 1; wait; + KGCN # 1; wait; select0: - KGCM A 1; + KGCM # 1 { + updateOverlay(); + } goto select0big; deselect0: - KGCM A 1; + KGCM # 1 { + updateOverlay(); + } goto deselect0big; ready: - KGCM A 1 { + KGCM B 1 { A_Overlay(355, "needle_indicator"); A_OverlayPivotAlign(355, PSPA_CENTER, PSPA_BOTTOM); - UpdateDisplay(); - A_WeaponReady(WRF_NOFIRE | WRF_ALLOWUSER3); // USER3 = MagManager. + // invoker.UpdateDisplay(); + updateOverlay(); + + A_WeaponReady(WRF_ALLOWUSER3); // USER3 = MagManager. } goto readyend; + fire: + KGCM # 1 offset(0, 20) { updateOverlay(); } + KGCM # 1 offset(0, 40) { updateOverlay(); } + KGCM # 1 offset(0, 55) { updateOverlay(); } + + KGCM # 1 { + invoker.onSwitch = !invoker.onSwitch; + console.printf("onswitch: %d", int(invoker.onSwitch)); + // TODO: Play sound. + updateOverlay(); + } + + KGCM # 1 offset(0, 55) { updateOverlay(); } + KGCM # 1 offset(0, 40) { updateOverlay(); } + KGCM # 1 offset(0, 20) { updateOverlay(); } + KGCM # 1 offset(0, 0) { updateOverlay(); } + goto waiting; + + waiting: + KGCM # 1 { updateOverlay(); } + KGCM # 1 { updateOverlay(); } + KGCM # 1 { updateOverlay(); } + KGCM # 1 { updateOverlay(); } + KGCM # 1 { updateOverlay(); } + KGCM # 1 A_Refire("waiting"); + goto ready; + readyend: #### # 0 A_ReadyEnd(); #### # 0 A_Jump(256,"ready"); } - action float GetReadingForType(String type_name, float distance_scale) + action void updateOverlay() + { + float angle_min = -45.0; + float angle_max = 45.0; + A_OverlayRotate(355, + angle_min + (angle_max - angle_min) * (1.0 - invoker.needlePosition)); + + player.getpsprite(PSP_WEAPON).frame = int(invoker.onSwitch); + player.getpsprite(355).frame = int(invoker.onSwitch); + // frame = int(invoker.onSwitch); + } + + float GetReadingForType(String type_name, float distance_scale) { ThinkerIterator iter = ThinkerIterator.Create(type_name); Actor mo; float totalReading = 0.0; + + Actor referenceActor = owner; + if(!referenceActor) { + referenceActor = self; + } + while(mo = Actor(iter.Next())) { - //shardCount++; - float dist = Distance3D(mo); + if(mo.health <= 0) { + continue; + } + + float dist = referenceActor.Distance3D(mo); // Convert to "meters" (with a minimum). if(dist < 32) { @@ -96,26 +151,28 @@ class GretchenCounter : HDWeapon dist *= distance_scale; - console.printf("%s", type_name); + // console.printf("%s", type_name); totalReading += 1.0 / (dist * dist); } return totalReading; } - // override void Tick() - // { - // super.Tick(); - // UpdateDisplay(); - // } - - action void UpdateDisplay() + override void Tick() { - float angle_min = -45.0; - float angle_max = 45.0; + // console.printf("lsjksdjklcmsdlkmcsdlkmslckmlkmsdclkmsdclkmsdc"); + super.Tick(); + UpdateDisplay(); + } + void UpdateDisplay() + { + Actor referenceActor = owner; + if(!referenceActor) { + referenceActor = self; + } - // console.printf("kjsdcsjkdcnsdjkcnsdkjcnsdc"); + console.printf("kjsdcsjkdcnsdjkcnsdkjcnsdc, %d", int(onSwitch)); // ThinkerIterator iter = ThinkerIterator.Create("BFGNecroShard"); // Actor mo; @@ -139,21 +196,24 @@ class GretchenCounter : HDWeapon // shardCount += 1; // } - float totalReading = - GetReadingForType("BFGNecroShard", 1.0) + - GetReadingForType("HDBarrel", 2.0); + float totalReading = 0.0; + if(onSwitch) { + totalReading = + GetReadingForType("BFGNecroShard", 1.0) + + GetReadingForType("HDBarrel", 2.0); + } - // invoker.lastReading = totalReading * 0.01 + invoker.lastReading * 0.99; + // lastReading = totalReading * 0.01 + lastReading * 0.99; - float pct_reading = invoker.lastReading * 2000.0; + float pct_reading = lastReading * 2000.0; - invoker.lastReading = totalReading; + lastReading = totalReading; float r = frandom(0.0, 1.0); - if(r < pct_reading) + if(r < pct_reading && onSwitch) { - console.printf("test: %f %f", r, pct_reading); - A_StartSound("kiri/gretchencounter_click"); + // console.printf("test: %f %f", r, pct_reading); + referenceActor.A_StartSound("kiri/gretchencounter_click"); } @@ -162,15 +222,15 @@ class GretchenCounter : HDWeapon // } - String meter_str = ""; - float k; - for(k = 0.0; k < 1.0; k += 0.02) { - if(k < pct_reading) { - meter_str = meter_str.."#"; - } else { - meter_str = meter_str.."_"; - } - } + // String meter_str = ""; + // float k; + // for(k = 0.0; k < 1.0; k += 0.02) { + // if(k < pct_reading) { + // meter_str = meter_str.."#"; + // } else { + // meter_str = meter_str.."_"; + // } + // } // if(pct_reading > 1.0) { // pct_reading = 1.0; @@ -179,25 +239,28 @@ class GretchenCounter : HDWeapon // angle_min + (angle_max - angle_min) * (1.0 - pct_reading)); - invoker.angularvelocity += pct_reading - invoker.needlePosition; - invoker.angularvelocity *= 0.97; + angularvelocity += pct_reading - needlePosition; + angularvelocity *= 0.97; - bool wasNeedleAtMax = (invoker.needlePosition >= 0.9); + bool wasNeedleAtMax = (needlePosition >= 0.9); - invoker.needlePosition += invoker.angularvelocity * 0.1; - invoker.needlePosition = clamp(invoker.needlePosition, 0.0, 1.0); - - A_OverlayRotate(355, - angle_min + (angle_max - angle_min) * (1.0 - invoker.needlePosition)); - - console.printf("Ang vel %f", invoker.angularvelocity); - console.printf("Shard count: [%s] %f", meter_str, pct_reading); + needlePosition += angularvelocity * 0.1; + needlePosition = clamp(needlePosition, 0.0, 1.0); - invoker.framesSinceLastBeep++; - if((!wasNeedleAtMax || invoker.framesSinceLastBeep > 15) && invoker.needlePosition >= 0.9) { - A_StartSound("kiri/gretchencounter_blip"); - invoker.framesSinceLastBeep = 0; + // console.printf("Ang vel %f", angularvelocity); + // console.printf("Shard count: [%s] %f", meter_str, pct_reading); + + + framesSinceLastBeep++; + // if(onSwitch) + { + if(!wasNeedleAtMax || framesSinceLastBeep > 15) { + if(needlePosition >= 0.9) { + referenceActor.A_StartSound("kiri/gretchencounter_blip"); + framesSinceLastBeep = 0; + } + } } }