January 21, 2021, 02:25:38 AM

Author Topic: BattleStar Scanner Wars TEXT only  (Read 564 times)

Offline mainsworthy

  • Jr. Member
  • **
  • Posts: 44

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 2057
Re: BattleStar Scanner Wars TEXT only
« Reply #1 on: May 01, 2020, 06:57:30 AM »
Thanks for sharing :)

Offline mainsworthy

  • Jr. Member
  • **
  • Posts: 44
Re: BattleStar Scanner Wars TEXT only
« Reply #2 on: May 01, 2020, 07:19:08 AM »
thanks Adam, Ive gone text mad :) I saw a game by you I of Us did well in 7drl 2018, I shall have to enter next year

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 2057
Re: BattleStar Scanner Wars TEXT only
« Reply #3 on: May 01, 2020, 08:11:52 AM »
Quote
Ive gone text mad
LOL  ;D

If you really like the text then have a look at:
https://www.gridsagegames.com/cogmind/ which takes ascii/text into the next level

Great place to start if you want to be inspired :)


Offline mainsworthy

  • Jr. Member
  • **
  • Posts: 44
Re: BattleStar Scanner Wars TEXT only
« Reply #4 on: May 01, 2020, 11:55:55 AM »
thanks, I actualy bought it but not played yet

Offline Xerra

  • Hero Member
  • *****
  • Posts: 1207
  • Wait, what? This isn't Porn Hub?
    • Retro Evolved
Re: BattleStar Scanner Wars TEXT only
« Reply #5 on: May 02, 2020, 09:22:36 PM »
Oh, man. That so reminds me of when I woke up with a stinking hangover on 1st Jan, 2014 and wrote my own text version of "Hunt the Wumpus!" in Blitzmax. I just had to boot up NG and run that again :)

Remember me posting this, Adam? You did comment on it but it was a looooong time ago, lol.

Actually, have the source code. Seem to remember I posted it last time.

Code: [Select]

' Hunt the Wumpus by Tony Brice - January, 2014.
' Modified for OSX June 3, 2015.

' To Do:

' Light up all squares already moved over.
'
' Ideas:
' Expand grid size to 10 * 10 & adjust arrows, hazzards accordingly.
' Message box set up as a scrolling area of message text which can move up screen as new info displayed.
' Score system for number of Wumpus tracked and killed before dying. Could add 10 points each square moved or similar.
' Implement a torch that you can use once to highlight four squares around you.
' Wumpus can move a square in any random direction if he sniffs you. You can move first. If he enters pit, you win.

' Bugs:
' if you hold shift down then you can fire in all directions even if you are on your last shot.

SuperStrict
Import BRL.Random

' Toggle for debug mode
Global Debug:Byte = False

' Toggle for cheating
Global Showall:Byte = False

AppTitle:String = "Hunt the Wumpus !"
Global Width:Int = 800, Height:Int = 600, Depth:Int = 0
Graphics Width, Height, Depth
SetBlend ALPHABLEND
SetMaskColor 0, 0, 0
SeedRnd MilliSecs()
FlushKeys

' Players X and Y location on grid.
Global PlayerX:Int, PlayerY:Int = 0, PX:Int = 0, PY:Int = 0
Global WumpusKilled:Byte = False
Global Score:Int = 0 ' Score to be implemented.
Global Level:Int = 0 ' Levels to be implemented.

'Ingame toggles
Global GameOver:Byte = False ' Locks player movement if active because they have died.
Global GameStatus:Int = 0 ' Used to define game over condition eg: 3= left cave with wumpus still alive.
Global Help:Byte = False ' Toggle if help info is displayed in game.

' Playershot location on grid.
Global ShotFired:Byte = False ' If a shot has been fired then area highlighted until next turn.
Global ShotX:Int = 0, ShotY:Int = 0 ' X & Y location of shot square

' Never-ending pit location on grid.
Global PitX:Int = 0, PitY:Int = 0

' Wumpus location on grid.
Global WumpusX:Int, WumpusY:Int = 0

' Annoying bats location on grid.
Global BatsX:Int, BatsY:Int = 0

' Start with 3 arrows and there are a random amount more hidden in one square on grid.
Global NumberofArrows:Int = 0, ArrowX:Int = 0, ArrowY:Int = 0
Global ArrowsCollected:Byte = False

' Exit location on grid
Global ExitX:Int = 0, ExitY:Int = 0, ExitFound:Byte = False

' Message display
Global Message:String = " "
Global Warning:String = " "

' Define 5*5 grid. Could be expanded with a little work.
' Will need to define the grid using Drawtext "#" in a grid size for/next loop if you want different sizes.
Global MaxGridSizeX:Int = 5, MaxGridSizeY:Int = 5 ' Define grid size to make expanding easier later.
Global GridX:Int = 0, GridY:Int = 0
Global GridArray:Int[MaxGridSizeX, MaxGridSizeY]

Init() ' Set up the grid.

Repeat
Display()

If KeyHit(KEY_R)
' Reset the board
Init()
EndIf

If KeyHit(KEY_D)
' Toggle debug mode
If Debug = True
Debug = False
Else
Debug = True
EndIf
EndIf

If KeyHit(KEY_H) ' Display help screen.
If Help = True
Help = False
Message = " "
Else
Help = True
EndIf
EndIf

If KeyHit(KEY_C)
' Toggle if hazzards shown on grid.
If Showall = True
Showall = False
Else
Showall = True
EndIf
EndIf

If KeyHit(KEY_E) ' You can leave the cave alive if you find the exit before dying and are out of ammo.
If PlayerX = ExitX And PlayerY = ExitY
Message = "You leave the cave safely !"
Warning = " "
GameOver = True
GameStatus = 6 ' Exit the cave with Wumpus still alive.
End If
End If

If KeyHit(KEY_A) ' if cheat on then you can press A for 100 arrows - for testing.
If Showall = True
NumberofArrows = 100
EndIf
EndIf

If GameOver = False

If KeyHit(KEY_DOWN) And PlayerY < 4
If KeyDown(KEY_LSHIFT) Or KeyDown(KEY_RSHIFT)
ShotX = PlayerX ; ShotY = PlayerY + 1
Fire()
Else
PlayerY:+1
Movement()
EndIf
EndIf

If KeyHit(KEY_UP) And PlayerY > 0
If KeyDown(KEY_LSHIFT) Or KeyDown(KEY_RSHIFT)
ShotX = PlayerX ; ShotY = PlayerY - 1
Fire()
Else
PlayerY:-1
Movement()
EndIf
EndIf

If KeyHit(KEY_LEFT) And PlayerX > 0
If KeyDown(KEY_LSHIFT) Or KeyDown(KEY_RSHIFT)
ShotX = PlayerX - 1 ; ShotY = PlayerY
Fire()
Else
PlayerX:-1
Movement()
EndIf
EndIf

If KeyHit(KEY_RIGHT) And PlayerX < 4
If KeyDown(KEY_LSHIFT) Or KeyDown(KEY_RSHIFT)
ShotX = PlayerX + 1 ; ShotY = PlayerY
Fire()
Else
PlayerX:+1
Movement()
EndIf
EndIf

Else ' Game Over has been triggered.

If GameStatus = 0 ' Wumpus caught you.
Message = "Roar! The wumpus caught you !"
Warning = "You've been consumed. Yuck !"
WumpusKilled = False
End If

If GameStatus = 2 ' Fell in the pit.
Message = "You fell in the never ending pit."
Warning = "AAAAaaaarrrrggghhh !!!!!"
WumpusKilled = False
End If

If GameStatus = 1 ' Killed the Wumpus.
Message = "Splat! You just nailed that Wumpus !"
Warning = "Well done !"
WumpusKilled = True
EndIf

If GameStatus = 6 ' Exit the cave alive.
WumpusKilled = True
EndIf

If WumpusKilled = False
SetColor 255, 0, 0 ' Red
DrawText "** Game Over ** You were killed !", 250, 100
Else
SetColor 0, 255, 0 ' Green
DrawText "** Well Done ** You won the game !", 250, 100
EndIf

SetColor 0, 100, 200
DrawText "Press 'R' to Restart", 300, 120
EndIf

Flip
Until KeyHit(KEY_ESCAPE)
End

Function Movement()
Local t:Int = 0
Help = False ' Turn off help screen or results of movement will be unknown.
'Message = " "; Warning = " " ' Clear the status displays so player notices new warnings.

If ShotFired = True
ShotFired = False ' Player moved so cancel displaying the shot and remove from grid.
GridArray[ShotX, ShotY] = 0
EndIf

If GridArray[PlayerX, PlayerY] = 0 ' Player in empty square.
Message = "You are searching the cave."
End If

If GridArray[PlayerX, PlayerY] = 4
If ArrowsCollected = False
ArrowsCollected = True
NumberofArrows:+Rand(1, 5)
Message = "Excellent. You found more arrows."
EndIf
EndIf

If GridArray[PlayerX, PlayerY] = 1
GameOver = True
GameStatus = 0 ' Walked into the Wumpus.
EndIf

If GridArray[PlayerX, PlayerY] = 6
ExitFound = True
Message = "Exit found ! Press `E` to Escape."
EndIf

If GridArray[PlayerX, PlayerY] = 2
GameOver = True
GameStatus = 2 ' Fell into the pit
EndIf

If GridArray[PlayerX, PlayerY] = 3
Message = "Bats found you & dropped you somewhere."
t = 0
Repeat
PlayerX = Rand(0, 4) ; PlayerY = Rand(0, 4)
If GridArray[PlayerX, PlayerY] = 0
t = 1
Else
t = 0
EndIf
Until t = 1
EndIf

' ** Check squares adjacent to player because they have moved. **

Warning = " "

If PlayerX > 0 ' Check East.
NearbyHazzard(PlayerX - 1, PlayerY)
EndIf

If PlayerX < 4 ' Check West.
NearbyHazzard(PlayerX + 1, PlayerY)
EndIf

If PlayerY > 0 ' Check North.
NearbyHazzard(PlayerX, PlayerY - 1)
EndIf

If PlayerY < 4 ' Check South
NearbyHazzard(PlayerX, PlayerY + 1)
EndIf

End Function

Function Lights()

' ** Working here ..... **



' Light up each square on grid already visited.
' May want to stop arrows displaying once they have been collected when this is working.

Local x:Int = 0, y:Int = 0
For x = 0 To 4
For y = 0 To 4
DrawText "@", 25 + (PlayerX * 40), 60 + (PlayerY * 50) ' Draw player on grid.
Next
Next

End Function

Function NearbyHazzard(xx:Int, yy:Int)

If GridArray[xx, yy] = 1
Warning = "You can hear snoring nearby !"
End If

If GridArray[xx, yy] = 2
Warning = "You can hear your footsteps echo !"
End If

If GridArray[xx, yy] = 3
Warning = "There's squeaking nearby !"
End If

If GridArray[xx, yy] = 6
Warning = "There's a light in the distance !"
End If

End Function

Function Fire()
Local t:Int = gridarray[shotx, shoty]
Help = False ' Turn off help screen or results of shot will be unknown.
If NumberofArrows > 0
NumberofArrows:-1
ShotFired = True
Message = "You fire into empty space !"
If t = 0
GridArray[ShotX, ShotY] = 5
EndIf

If t = 1
GameOver = True ; WumpusKilled = True
GameStatus = 1
End If

If t = 2
Message = "You hear your shot whistle over a pit !"
ShotFired = False
EndIf

If t = 3
Message = "You hear the fluttering of wings !"
ShotFired = False
End If

If t = 4
If ArrowsCollected = False ' if you have collected arrows already then there would be no ricochet.
Message = "Your shot bounced off something !"
ShotFired = False
EndIf
EndIf

If t = 6
Message = "You hear an echo in the distance !"
ShotFired = False
End If

Else
Message = "You are out of ammunition !"
EndIf

End Function

Function Init()

' This is a bit fiddly how I've done the starting locations but it was the best way I could think of ensuring
' each hazzard was on its own square in the grid as it would be useless for the pit and wumpus to be in the
' same place, for example.

' Note it is theoretically possible for the Exit to be located on a square in the corner and a wumpus under it with
' a hole on the side so you could possibly never win. However, having an exit square does mean you could leave the
' cave, so this may not be an issue. If you are going to highlight the squares , when moved over or hazzards located,
' this this could become obvious to the player........

Local t:Byte = 0
GameOver = False
NumberofArrows = 3
ArrowsCollected = False
Warning = " "
ShotFired = False
WumpusKilled = False
ExitFound = False
GameStatus = 0

' Empty the grid so you dont endlessly loop looking for an empty location. Thanks, Jsp.
For t = 0 To 4
GridArray[0, t] = 0
GridArray[1, t] = 0
GridArray[2, t] = 0
GridArray[3, t] = 0
GridArray[4, t] = 0
Next

' Place the Wumpus on grid. [1]
WumpusX = Rand(0, MaxGridSizeX - 1) ; WumpusY = Rand(0, MaxGridSizeY - 1)
GridArray[WumpusX, WumpusY] = 1

' Place the arrows on grid. [4]
Repeat
ArrowX = Rand(0, MaxGridSizeX - 1) ; ArrowY = Rand(0, MaxGridSizeY - 1)
If GridArray[ArrowX, ArrowY] > 0
t = 0
Else
t = 1
GridArray[ArrowX, ArrowY] = 4
EndIf
Until t = 1

' Place the pit on grid. [2]
t = 0
Repeat
PitX = Rand(0, MaxGridSizeX - 1) ; PitY = Rand(0, MaxGridSizeY - 1)
If GridArray[PitX, PitY] > 0
t = 0
Else
t = 1
GridArray[PitX, PitY] = 2
EndIf
Until t = 1

' Place the bats on grid. [3]
t = 0
Repeat
BatsX = Rand(0, MaxGridSizeX - 1) ; BatsY = Rand(0, MaxGridSizeY - 1)

If GridArray[BatsX, BatsY] > 0
t = 0
Else
t = 1
GridArray[BatsX, BatsY] = 3
EndIf
Until t = 1

' Place the exit on grid. [6]
t = 0
Repeat
ExitX = Rand(0, MaxGridSizeX - 1) ; ExitY = Rand(0, MaxGridSizeY - 1)

If GridArray[ExitX, ExitY] > 0
t = 0
Else
t = 1
GridArray[ExitX, ExitY] = 6
EndIf
Until t = 1

' Player to start in a random location.

' This part checks all squares in the grid so the player can be put on a blank one so it won't be instant game over
' if they were deposited on a pit, for example. A similar check is done when the bats move the player.

t = 0
Repeat
PlayerX = Rand(0, 4) ; PlayerY = Rand(0, 4)
If GridArray[PlayerX, PlayerY] = 0
t = 1
Else
t = 0
EndIf
Until t = 1
Movement() ' Updates location message so player has fair warning if hazzard nearby at start.
End Function

Function Display()
Cls
SetColor 100, 100, 255 ' Blue shade
DrawText AppTitle, 45, 10
SetColor 255, 0, 0 ' Red
DrawText "###########################", 0, 30
DrawText "###########################", 0, 40
DrawText "##   ##   ##   ##   ##   ##", 0, 50
DrawText "##   ##   ##   ##   ##   ##", 0, 60
DrawText "##   ##   ##   ##   ##   ##", 0, 70
DrawText "###########################", 0, 80
DrawText "###########################", 0, 90
DrawText "##   ##   ##   ##   ##   ##", 0, 100
DrawText "##   ##   ##   ##   ##   ##", 0, 110
DrawText "##   ##   ##   ##   ##   ##", 0, 120
DrawText "###########################", 0, 130
DrawText "###########################", 0, 140
DrawText "##   ##   ##   ##   ##   ##", 0, 150
DrawText "##   ##   ##   ##   ##   ##", 0, 160
DrawText "##   ##   ##   ##   ##   ##", 0, 170
DrawText "###########################", 0, 180
DrawText "###########################", 0, 190
DrawText "##   ##   ##   ##   ##   ##", 0, 200
DrawText "##   ##   ##   ##   ##   ##", 0, 210
DrawText "##   ##   ##   ##   ##   ##", 0, 220
DrawText "###########################", 0, 230
DrawText "###########################", 0, 240
DrawText "##   ##   ##   ##   ##   ##", 0, 250
DrawText "##   ##   ##   ##   ##   ##", 0, 260
DrawText "##   ##   ##   ##   ##   ##", 0, 270
DrawText "###########################", 0, 280
DrawText "###########################", 0, 290
SetColor 0, 255, 0 ' Green.
DrawText "Arrows remaining: " + NumberofArrows, 40, 310

SetColor 255, 255, 255 ' White.
DrawText "Use cursor keys to move & hold Shift with cursor keys to fire an arrow.", 0, 360

SetColor 0, 255, 0 ' Green
DrawText "@", 25 + (PlayerX * 40), 60 + (PlayerY * 50) ' Draw player on grid.

If Exitfound = True Or Showall = True ' if cheating is true or the exit has been located.
SetColor 0, 200, 100 ' ??
DrawText "E", 25 + (ExitX * 40), 60 + (ExitY * 50) ' Draw exit on grid.
EndIf

SetColor 30, 60, 90
DrawText "Created by Tony Brice - Updated June 3rd, 2015 for OSX", 0, 450

If Help = True
SetColor 0, 255, 200
DrawText "Harry the Hunter, is on the hunt.", 235, 50
DrawText "A few arrows and his trusty bow", 235, 70
DrawText "are all he needs to kill that nasty,", 235, 80
DrawText "smelly Wumpus but be cautious as", 235, 90
DrawText "there are some deadly hazzards in this", 235, 100
DrawText "cave that are really bad for your", 235, 110
DrawText "health...", 235, 120
DrawText "Run out of Ammo? Then look for", 235, 140
DrawText "the exit.", 235, 150
DrawText "Watch out for important messages ", 235, 170
DrawText "as you move around. They may just ", 235, 180
DrawText "save your life...", 235, 190
Else
SetColor 255, 255, 255
DrawText "Messages: ", 235, 30
DrawText "Warning: ", 235, 50
DrawText Message, 320, 30
SetColor 255, 0, 0 ' Red
DrawText Warning, 320, 50
SetColor 255, 255, 255 ' White
End If

If Debug = True
SetColor 255, 0, 255 ' Pink.
DrawText "Debug mode is on:", 0, 400
DrawText "X: " + MouseX() + " Y: " + MouseY(), 145, 400
PX = PlayerX + 1 ; PY = PlayerY + 1
DrawText "Player location : X=" + PX + " , Y=" + PY, 0, 410
DrawText "/ Exit located: ", 225, 410
If ExitFound = True
DrawText "Yes", 350, 410
Else
DrawText "No", 350, 410
EndIf
DrawText "Arrows collected: ", 0, 420
If ArrowsCollected = True
DrawText "Yes", 145, 420
Else
DrawText "No", 145, 420
EndIf
SetColor 255, 255, 255 ' White
DrawText "R to Reset / H for help / Esc to exit / C to cheat.", 0, 350
Else
DrawText "R to Reset / H for help / Esc to exit.", 0, 350
EndIf

If ShotFired = True
' Show where a shot has been fired if active.
SetColor 255, 0, 0 ' Red
DrawText "%", 25 + (ShotX * 40), 60 + (ShotY * 50)
EndIf

If Showall = True
' Cheat mode toggled by pressing "C"
SetColor 255, 0, 0 ' Red.
DrawText "Player is Cheating", 45, 330
SetColor 0, 255, 255 ' Cyan
DrawText "W", 25 + (WumpusX * 40), 60 + (WumpusY * 50)
SetColor 100, 100, 100 ' Grey
DrawText "H", 25 + (PitX * 40), 60 + (PitY * 50)
SetColor 100, 200, 100 ' Dull green
DrawText "B", 25 + (BatsX * 40), 60 + (BatsY * 50)
SetColor 0, 0, 255 ' Blue
DrawText "^", 25 + (ArrowX * 40), 60 + (ArrowY * 50)
EndIf

EndFunction


Offline mainsworthy

  • Jr. Member
  • **
  • Posts: 44
Re: BattleStar Scanner Wars TEXT only
« Reply #6 on: May 02, 2020, 11:20:10 PM »
Xerra that looked like you had fun.

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 2057
Re: BattleStar Scanner Wars TEXT only
« Reply #7 on: May 03, 2020, 08:21:46 AM »
nice tight code Xerra, I may just have to do a compile and nick it :)

One thing that springs to mind is the display used in both Xerra and Mainsworthy:
My preference (looks wise) is xerras version with the more compressed visuals with no gap between lines

Another observation:
I did a quick check of both displays.
Xerras uses approx 95 columns across and Mainsworthy uses 128 columns across

You might find it better to standardise on the more common 80 columns 40 or 50 or 60 lines vertically

This would reduce the amount of text, make it a bit bigger and less of a 'sea of text' look.
If you used an IBM base font and also use extended graphics, you could develop an ascii style which is more 'in tune' with the retro look that people like
Just a thought :)






Offline Xerra

  • Hero Member
  • *****
  • Posts: 1207
  • Wait, what? This isn't Porn Hub?
    • Retro Evolved
Re: BattleStar Scanner Wars TEXT only
« Reply #8 on: May 03, 2020, 08:59:59 AM »
As I recall, I was using a really crappy non-widescreen monitor in those days, so never really did anything outside of 1024/768. I had to recompile this to take a screenshot as I'd put it in full screen mode as well, which was pretty pointless for a text game like this.

Looking at the code it's pretty ugh now. I've not used blitz much since then but, if I went back to it now, I reckon I could optimise that a lot better. My excuse is I was hungover when I did it :-)

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal