-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.hs
55 lines (46 loc) · 2.21 KB
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
module Main where
import System.Random
import Graphics.Gloss
import Graphics.Gloss.Interface.IO.Game
import Level
import Screen
import Mob
import Battle
import Util
main :: IO ()
--main = sMain
main = do
lv' <- genLevel 33 59
let lv = boundLevel lv'
alien <- spaceman (5,5)
stairs <- stairs (10,10)
let testWorld = Overworld lv startingPlayer [alien, stairs]
let testbattle = Battle testWorld startingPlayer [alien, stairs] (True,True) (State None AttackM) True
playIO FullScreen red 5 testbattle renderWorld handleInput idstep
idstep _ w@(Overworld l p lm) = do
let newMonsters = map (\m -> monsterThink m w) lm
let pp = pos p
let cols = filter (\m -> posM m == pp) newMonsters
if not $ null $ filter (\m -> nameM m == "stairs") cols then do
lv' <- genLevel 33 59
let lv = boundLevel lv'
alien <- spaceman (7,5)
let testWorld = Overworld lv startingPlayer [alien{nameM="stairs"},alien{posM=(10,7)}]
return testWorld
else do
return $ Overworld l p newMonsters
stepBattle :: Float -> World -> IO World
stepBattle _ here@(Battle w p ms sel (State pa ma) turn) | null ms = return w
| pa == None = return here
| otherwise = if turn then case pa of
Run -> return w
Attack -> do
g <- getStdGen
let (idx,g') = choice g [0..length ms]-- :: (Int,StdGen)
let m = attackMob p (ms !! idx)
return $ case m of
Just m' -> Battle w p (replace ms idx m') sel (State None ma) False
Nothing -> Battle w p (remove ms idx) sel (State None ma) False
Item _ -> return here
Ability _ -> return here
else return here