initial commit, carried over from code sketch

This commit is contained in:
lee2sman 2020-11-01 17:49:27 -05:00
commit b7880abfa3
55 changed files with 440 additions and 0 deletions

10
README.md Normal file
View File

@ -0,0 +1,10 @@
Audio:
[Uighur Traditional music, recording 2. (Instrumental)](https://freesound.org/people/RTB45/sounds/192677/) by RTB45 on Freesound.com, recorded in Turpan/Turfan/Tulufan
Excerpt from [Desert insects](https://freesound.org/people/bruno.auzet/sounds/528081/) by Bruno Auzet on Freesound.com, recorded in Biskra, Algeria
TODO:
- add more possibilities for interactions with nomads, more search results
- add gold?
- when oasis roll generates that it won't be displayed, then have text say "You thought you saw an oasis ahead, but as you keep marching along it keeps appearing on the horizon and you realize with this heat it's actually just a mirage."

BIN
assets/bluff.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 KiB

BIN
assets/city.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 KiB

BIN
assets/desert/0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 KiB

BIN
assets/desert/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 KiB

BIN
assets/desert/10.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 KiB

BIN
assets/desert/11.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 KiB

BIN
assets/desert/12.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 KiB

BIN
assets/desert/13.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 KiB

BIN
assets/desert/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 KiB

BIN
assets/desert/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

BIN
assets/desert/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 KiB

BIN
assets/desert/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 KiB

BIN
assets/desert/6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 KiB

BIN
assets/desert/7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 KiB

BIN
assets/desert/8.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 KiB

BIN
assets/desert/9.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 KiB

Binary file not shown.

Binary file not shown.

BIN
assets/fort.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 KiB

BIN
assets/nomads/0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

BIN
assets/nomads/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 KiB

BIN
assets/nomads/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 KiB

BIN
assets/nomads/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 KiB

BIN
assets/nomads/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 KiB

BIN
assets/nomads/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 KiB

BIN
assets/nomads/6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 KiB

BIN
assets/nomads/7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 KiB

BIN
assets/oasis/0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 KiB

BIN
assets/oasis/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 KiB

BIN
assets/oasis/10.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 KiB

BIN
assets/oasis/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

BIN
assets/oasis/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 KiB

BIN
assets/oasis/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 KiB

BIN
assets/oasis/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 791 KiB

BIN
assets/oasis/6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 KiB

BIN
assets/oasis/7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 KiB

BIN
assets/oasis/8.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 KiB

BIN
assets/oasis/9.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 KiB

BIN
assets/ruins/0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 KiB

BIN
assets/ruins/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 KiB

BIN
assets/ruins/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 KiB

BIN
assets/ruins/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 KiB

BIN
assets/ruins/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 KiB

BIN
assets/ruins/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 KiB

BIN
assets/ruins/6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 KiB

BIN
assets/ruins/7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 KiB

BIN
assets/sound/bg.mp3 Normal file

Binary file not shown.

BIN
assets/sound/insects.mp3 Normal file

Binary file not shown.

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

34
index.html Normal file
View File

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>
Gobi
</title>
<script src="js/p5.min.js"></script>
<script src="js/p5.sound.min.js"></script>
<link rel="stylesheet" href="main.css" />
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
<div class="container">
<img id="photo" src="" />
<div id="ui">
<div id="buttons">
<div class='actions' id='advance'>Advance</div>
<div class='actions' id='rush'>Rush</div>
<div class='actions' id='rest'>Rest</div>
<div class='actions' id='search'>Search</div>
<br>
<div class='actions' id='soundtrack'>Soundtrack ON/OFF</div>
</div>
<p id="console"></p>
</div>
</div>
<script src="js/main.js"></script>
</body>
</html>

312
js/main.js Normal file
View File

@ -0,0 +1,312 @@
//gobi by lee2sman 2020
//an attempt at recreating a lost favorite 90s Mac system 9 shareware game, original title unknown
let progress = 1, goal = 50, water = 20, food = 20, camelHealth = 5
let currentScene, nextScene
let oasisCount = 11, nomadsCount = 8, ruinsCount = 8, desertCount = 14
let oasisImg = [], nomadsImg = [], ruinsImg = [], desertImg = [], cityImg
let soundtrack, insects
function setup(){
noCanvas()
currentScene = chooseScene()
nextScene = chooseScene()
debug()
start()
//load soundtrack
soundFormats('mp3');
soundtrack = loadSound('assets/sound/bg.mp3')
insects = loadSound('assets/sound/insects.mp3')
//event loop
select('#advance').mousePressed(advance)
select('#rush').mousePressed(rush)
select('#rest').mousePressed(rest)
select('#search').mousePressed(search)
//nav
select('#soundtrack').mousePressed(soundtrackToggle)
}
/*
function keyPressed(){
if (key == ' '){ //rush
rush()
} else if (key == 'r'){ //rest
rest()
} else if (key =='s'){ //search
search()
} else {
advance()
}
main()
}
*/
function main(){
select('#console').html(food+' <em>meals</em> | '+water+' <em>canteens</em> | '+progress+' <em>days</em><br><br>')
select('#console').html('<strong>'+currentScene.name.charAt(0).toUpperCase()+ currentScene.name.slice(1)+ '</strong><br><br>',true)
background(255)
if (currentScene.name == 'oasis'){
oasis()
} else if (currentScene.name == 'nomads'){
nomads()
} else if (currentScene.name == 'ruins'){
ruins()
} else if (currentScene.name == 'desert'){
desert()
} else {
print('error')
}
//decrease food
food--
//decrease water
water--
checkHealth()
checkProgress()
printInfo()
debug()
}
function chooseScene(){
let sceneProb = random()
if (sceneProb > 0.9) { //10% chance of oasis
return {
name: 'oasis',
imgNum: int(random(oasisCount))
}
} else if (sceneProb > 0.8){ //10% chance of nomads
return {
name: 'nomads',
imgNum: int(random(nomadsCount))
}
} else if (sceneProb > 0.7){ //10% chance of ruins
return {
name: 'ruins',
imgNum: int(random(ruinsCount))
}
} else {
return {
name: 'desert',
imgNum: int(random(desertCount))
}
}
}
function start(){
select('#photo').attribute('src','assets/fort.jpg')
select('#console').html("You are a trader, having traveled far and wide along the silk road to buy and sell wares. Now far from home as the season starts to turn you begin the long journey back home, through the Gobi desert.<br><br>You'll need your supplies to hold out, and a little luck, to make it home in 50 days.")
}
function oasis(){
select('#photo').attribute('src','assets/oasis/'+currentScene.imgNum+'.jpg')
select('#console').html("You refill your water and rest your camel. ")
if (camelHealth < 5){
camelHealth++
}
//refill water
water = 20
progress++
}
function nomads(){
select('#photo').attribute('src','assets/nomads/'+currentScene.imgNum+'.jpg')
let event = random()
if (event < 0.03){ //3% chance
select('#console').html("The nomads attack you to get your supplies. They steal all your food and water. ",true)
food = 0
water = 0
} else if (event < 0.3){ //27% chance
select('#console').html("The nomads attack and steal some of your food and water. ",true)
food-=int(random(2,5))
water-=int(random(2,5))
} else if (event < 0.5) { //20% chance
select('#console').html("This looks like a rough group. You steer wide around their party, hoping they will ignore you. ",true)
} else { //50% chance
select('#console').html("The nomads are a friendly group. You travel together for a bit and they give you some food and drink. ",true)
water+=int(random(2,8)) //increase water
if (water>20)(water= 20) //but there are limits!
food+=int(random(2,8)) //increase food
if (food>24)(food = 24) //but there are limits!
progress++
}
}
function ruins(){
select('#photo').attribute('src','assets/ruins/'+currentScene.imgNum+'.jpg')
select('#console').html("You come across some ruins and search for supplies.",true)
let event = random()
if (event < 0.3){
select('#console').html(" You find the remains of some leftover meal abandoned in an old firepit. ",true)
food+=int(random(2,8)) //increase food
if (food>24)(food = 24) //but there are limits!
} else if (event <0.5){
select('#console').html(" You find a canteen with some water. ",true)
water+=int(random(2,8)) //increase water
if (water>20)(water= 20) //but there are limits!
} else {
select('#console').html(" You don't find anything. ",true)
}
progress++
}
function desert(){
select('#photo').attribute('src','assets/desert/'+currentScene.imgNum+'.jpg')
progress++
}
function printInfo(){
if (nextScene.name == 'nomads'){
if (random()<0.7){ //70% chance of spotting nomads in advance
select('#console').html('You see nomads ahead.',true)
}
} else if (nextScene.name == 'ruins'){
if (random()<0.5){ //50% chance of spotting ruins in advance
select('#console').html('You see ruins ahead.',true)
}
} else if (nextScene.name == 'oasis'){
select('#console').html('You see an oasis ahead!',true)
}
}
function checkHealth(){
if (food < 0){
select('#console').html('You die of starvation.',true)
die()
} else if (food < 3){
select('#console').html('You are hungry. ',true)
}
if (water < 0){
select('#console').html('You die of thirst.',true)
die()
} else if (water < 3){
select('#console').html('You are thirsty. ',true)
}
if (camelHealth < 0){
select('#console').html('Your camel is lame and cannot continue. You set out on foot but soon succumb to the heat. You die of heat stroke.')
die()
} else if (camelHealth < 3){
select('#console').html('Your camel is very sick. ',true)
} else if (camelHealth < 5){
select('#console').html('Your camel is sick. ',true)
}
}
function checkProgress(){
if (progress > goal){
select('#console').html("You crest a dune and see the outskirts of a city with hundreds of tents, market stalls and houses. In the distance is a great body of water. You can't wait to get home with your supplies and fortune. Your friends and family will certainly be pleased to see you. ")
select('#photo').attribute('src','assets/city.jpg')
}
}
function die(){
select('#photo').attribute('src','assets/bluff.jpg')
select('#console').html("The high desert air dries out your body. Wild animals soon come across your corpse, reducing you to bone. Over the weeks and years your remains scatter in the wind, blown up the bluffs, another nomad lost to the desert.")
select('.actions').hide()
insects.play()
}
function rush(){
select('#console').html("") //reset text in console
select('#console').html('You rush ahead, pushing your camel to its limit. It injures it slightly.')
currentScene = nextScene
nextScene = chooseScene()
//we do this twice! we are advancing fast!
currentScene = nextScene
nextScene = chooseScene()
progress++
camelHealth-=2
main()
}
function rest(){
select('#console').html("") //reset text in console
if (camelHealth<5){
camelHealth++
select('#console').html("You and your camel take a much needed rest.",true)
}
//we do not advance when resting
//
main()
}
function search(){
select('#console').html("") //reset text in console
//we do not advance when searching
let foodProb = random()
if (foodProb < 0.5){
select('#console').html("You search for food and find some berries that will sustain you for a while.",true)
food+=int(random(2,4))
} else {
select('#console').html("You search but don't come across anything you can eat.",true)
}
main()
}
function advance(){
select('#console').html("") //reset text in console
//important!
currentScene = nextScene
nextScene = chooseScene()
main()
}
function soundtrackToggle(){
if(soundtrack.isPlaying()){
soundtrack.pause()
} else {
soundtrack.loop()
}
}
function debug(){
print('currentScene: '+currentScene.name+'| nextScene: '+nextScene.name)
print('food: '+food+' | water: '+water+' | camelHealth: '+camelHealth+' progress: '+progress)
}

3
js/p5.min.js vendored Normal file

File diff suppressed because one or more lines are too long

28
js/p5.sound.min.js vendored Normal file

File diff suppressed because one or more lines are too long

53
main.css Normal file
View File

@ -0,0 +1,53 @@
@font-face {
font-family: roman;
src: url(assets/fonts/RomanAntique.ttf);
}
html,
body {
margin: 0;
padding: 0;
background-color: #d0c8b1;
font-family: roman;
display: flex;
justify-content: center;
align-items: center;
}
.container {
width: 80vw;
height: 100vh;
box-sizing: border-box;
display: flex;
}
#photo {
width: 60vw;
}
#ui {
background-color: #c1bc97;
width: 20vw;
font-size: x-large;
}
#buttons {
height: 50%;
border: 2px dotted;
display: flex;
flex-direction: column;
justify-content: space-around;
}
.actions {
height: 5vh;
border: dashed;
padding: 1vmin;
background-color: #d0c8b1;
}
#console {
height: 50%;
border: 2px dotted;
}
p {
padding: 1vmin;
line-height: 1em;
}