Browse Source

If, bullet transparency and speed, enter for textbox, auto restart after death.

tags/v1.0.1.0
soupi 1 year ago
parent
commit
dfd77c6636
8 changed files with 68 additions and 35 deletions
  1. +2
    -0
      README.md
  2. +5
    -0
      app/Script.hs
  3. +8
    -2
      app/Script/Boss.hs
  4. +18
    -8
      app/Script/Level1.hs
  5. +26
    -17
      app/Script/Level2.hs
  6. +6
    -6
      app/ShootingBox.hs
  7. +2
    -1
      app/TextBox.hs
  8. +1
    -1
      package.yaml

+ 2
- 0
README.md View File

@@ -2,6 +2,8 @@

A bullet hell game written in Haskell.

Click 'R' 5 times to expose a secret menu.

## How to Run

### From Source


+ 5
- 0
app/Script.hs View File

@@ -21,6 +21,7 @@ import qualified Play.Engine.Sprite as Spr
data Command
= Wait !Actions Int
| WaitUntil !Actions (Maybe IPoint -> [Enemy] -> Bool)
| If (Maybe IPoint -> [Enemy] -> Bool) Script
| Spawn (Result [Enemy])
| LoadTextBox !Actions (Result TB.TextBox)
| WaitTextBox !Actions TB.TextBox
@@ -82,6 +83,10 @@ update input mcPos enemies = \case
| test mcPos enemies -> pure (acts, rest)
| otherwise -> pure (acts, WaitUntil acts test : rest)

If test cmds : rest
| test mcPos enemies -> pure (noAction, cmds <> rest)
| otherwise -> pure (noAction, rest)

Spawn spawned : rest ->
(, rest) . (\s -> noAction { spawn = s }) <$> spawned



+ 8
- 2
app/Script/Boss.hs View File

@@ -12,6 +12,7 @@ import qualified GameState as GS
import qualified TextBox as TB
import qualified Data.Map as M
import qualified Script.End as End
import Data.Maybe (isNothing)


boss :: Bool -> Int -> Scene
@@ -78,7 +79,7 @@ lScript playMusic tryNum MySDL.Resources{ MySDL.textures = ts, MySDL.fonts = fs,
| tryNum < 7 ->
[ LoadTextBox act{ stopTheWorld = True } $
TB.make TB.Top 4
"Didn't you have enough yet?"
"Haven't you have enough yet?"
(M.lookup "astral-avatar" ts) (M.lookup "unispace" fs)
]
| tryNum < 10 ->
@@ -111,8 +112,13 @@ lScript playMusic tryNum MySDL.Resources{ MySDL.textures = ts, MySDL.fonts = fs,
] ++
-- Boss
[ Spawn $ sequence [Fast.make (Point 350 (-100)) ts]
, WaitUntil noAction (const $ null)
, WaitUntil noAction (\nyx bullets -> isNothing nyx || null bullets)

, If (const . isNothing)
[ Wait noAction 90
, FadeOut act{ command = Replace $ boss False (tryNum + 1) } 0
, Wait noAction 30
]
, StopMusic
, Wait act{ stopTheWorld = False } 2
, Wait act{ stopTheWorld = True } 150


+ 18
- 8
app/Script/Level1.hs View File

@@ -15,6 +15,8 @@ import qualified GameState as GS
import qualified Script.Level2 as L2
import qualified TextBox as TB
import qualified Data.Map as M
import Data.Maybe (isNothing)
import Data.List (intersperse)


level1 :: Bool -> Scene
@@ -50,8 +52,15 @@ lScript playMusic MySDL.Resources{ MySDL.textures = ts, MySDL.fonts = fs, MySDL.

, Wait noAction 60
] ++
intersperse
( If (const . isNothing)
[ Wait noAction 90
, FadeOut act{ command = Replace $ level1 False } 0
]
)

-- First sequence
concat
( concat
( replicate 3 $ concat
[ spawnStaticAndWait 200 300 ts
, spawnStaticAndWait 600 200 ts
@@ -94,12 +103,13 @@ lScript playMusic MySDL.Resources{ MySDL.textures = ts, MySDL.fonts = fs, MySDL.
, [spawnTwoCDEs (Right ()) (Left ()) ts]
] ++

-- First wave done
[ WaitUntil noAction (const $ null)
, Wait noAction 200
, Wait act{ stopTheWorld = True } 30
, Wait act{ command = Replace $ L2.level2 False } 60
]
-- First wave done
[ WaitUntil noAction (\nyx bullets -> isNothing nyx || null bullets)
, Wait noAction 200
, Wait act{ stopTheWorld = True } 30
, Wait act{ command = Replace $ L2.level2 False } 60
]
)

spawnTwoCDEs dir1 dir2 ts =
Spawn $ sequence
@@ -111,5 +121,5 @@ spawnStaticAndWait posx target ts =
[ Spawn $ sequence
[ St.make (Point posx (-100)) (Point 0 1) target ts
]
, Wait noAction 120
, Wait noAction 100
]

+ 26
- 17
app/Script/Level2.hs View File

@@ -13,6 +13,8 @@ import qualified GameState as GS
import qualified Script.Boss as Boss
import qualified TextBox as TB
import qualified Data.Map as M
import Data.Maybe (isNothing)
import Data.List (intersperse)


level2 :: Bool -> Scene
@@ -44,28 +46,34 @@ lScript playMusic MySDL.Resources{ MySDL.textures = ts, MySDL.fonts = fs, MySDL.
[ LoadTextBox act{ stopTheWorld = True } $
TB.make TB.Bottom 4 "This is harder than I expected..." (M.lookup "nyx-avatar" ts) (M.lookup "unispace" fs)
] ++
intersperse
( If (const . isNothing)
[ Wait noAction 60
, FadeOut act{ command = Replace $ level2 False } 0
]
)

-- Second wave
concat
( concat
[ [ Spawn $ sequence [CDE.make (Point 100 (-180)) (Right ()) ts]
, Wait noAction 100
, Wait noAction 50
]
, spawnStaticAndWait 400 300 ts
, spawnStaticAndWait 450 300 ts
, [ Spawn $ sequence [CDE.make (Point 700 (-180)) (Left ()) ts]
, Wait noAction 100
, Wait noAction 80
]
, [ Spawn $ sequence [CDE.make (Point 650 (-150)) (Left ()) ts]
, Wait noAction 100
, [ Spawn $ sequence [CDE.make (Point 600 (-150)) (Left ()) ts]
, Wait noAction 60
]
, [ Spawn $ sequence [CDE.make (Point 100 (-180)) (Right ()) ts]
, Wait noAction 100
, Wait noAction 40
]
, spawnStaticAndWait 600 300 ts
, spawnStaticAndWait 250 250 ts
, [ spawnTwoCDEs (Left ()) (Right ()) ts
, Wait noAction 100
, Wait noAction 70
, spawnTwoCDEs (Right ()) (Left ()) ts
, Wait noAction 100
, Wait noAction 70
]
, [ spawnTwoCDEs (Left ()) (Right ()) ts
, Wait noAction 60
@@ -79,13 +87,14 @@ lScript playMusic MySDL.Resources{ MySDL.textures = ts, MySDL.fonts = fs, MySDL.
]
] ++

-- Second wave done
[ WaitUntil noAction (const $ null)
, Wait noAction 200
, StopMusic
, Wait act{ stopTheWorld = True } 30
, Wait act{ command = Replace $ Boss.boss True 0 } 60
]
-- Second wave done
[ WaitUntil noAction (\nyx bullets -> isNothing nyx || null bullets)
, Wait noAction 200
, StopMusic
, Wait act{ stopTheWorld = True } 30
, Wait act{ command = Replace $ Boss.boss True 0 } 60
]
)

spawnTwoCDEs dir1 dir2 ts =
Spawn $ sequence
@@ -97,5 +106,5 @@ spawnStaticAndWait posx target ts =
[ Spawn $ sequence
[ St.make (Point posx (-100)) (Point 0 1) target ts
]
, Wait noAction 120
, Wait noAction 110
]

+ 6
- 6
app/ShootingBox.hs View File

@@ -94,7 +94,7 @@ mkMainChar ts = do
, mkTexture = nyxSprites
, mkSize = Point 180 380
, mkMaxPos = 4
, mkSpeed = 5
, mkSpeed = 6
}
, _bullet = nyxBullet
, _hitTimer = -1
@@ -183,17 +183,17 @@ update input mc = do
newBullet :: MainChar -> [Bullet]
newBullet mc
| mc ^. size . x == charSize ^. x =
[ mkBullet (mc ^. bullet) (Point 0 (-1)) mv 2 70 ((mc ^. pos) `addPoint` Point (mc ^. size . x `div` 4) 0)
, mkBullet (mc ^. bullet) (Point 0 (-1)) mv 2 70 ((mc ^. pos) `addPoint` Point ((mc ^. size . x `div` 4) * 3) 0)
[ mkBullet (mc ^. bullet) (Point 0 (-1)) mv 2 160 ((mc ^. pos) `addPoint` Point (mc ^. size . x `div` 4) 0)
, mkBullet (mc ^. bullet) (Point 0 (-1)) mv 2 160 ((mc ^. pos) `addPoint` Point ((mc ^. size . x `div` 4) * 3) 0)
]
| otherwise =
[ mkBullet (mc ^. bullet) (Point 0 (-1)) mv 5 140 ((mc ^. pos) `addPoint` Point (charSize ^. x `div` 2) 0)
[ mkBullet (mc ^. bullet) (Point 0 (-1)) mv 5 230 ((mc ^. pos) `addPoint` Point (charSize ^. x `div` 2) 0)
]

where
mv = MV.make $ MV.defArgs
{ MV.maxspeed = Point 0 10
, MV.accel = Point 0 10
{ MV.maxspeed = Point 0 13
, MV.accel = Point 0 5
}

checkHit :: [Bullet] -> MainChar -> MainChar


+ 2
- 1
app/TextBox.hs View File

@@ -94,7 +94,7 @@ plus1' n

update :: Input -> TextBox -> Result (Maybe TextBox)
update input tb
| keyClicked KeyA input
| keyClicked KeyA input || keyClicked KeyStart input
, let (l, t) = Zip.last (tb ^. text) in l == T.length t
= pure Nothing
| otherwise = do
@@ -117,6 +117,7 @@ update input tb
(\(txt :: Zip.ListZipper (Int, T.Text)) ->
if
| keyClicked KeyA input
|| keyClicked KeyStart input
|| tb ^. textSpeed == 0 ->
fmap (\(_, t) -> (T.length t, t)) txt
| tb ^. textTimer == 0


+ 1
- 1
package.yaml View File

@@ -1,5 +1,5 @@
name: nyx-game
version: 1.0.0.0
version: 1.0.1.0
license: Apache-2.0
author: "Gil Mizrahi"
maintainer: "gilmi@posteo.net"


Loading…
Cancel
Save