This commit is contained in:
lee2sman 2021-03-05 23:17:21 -05:00
parent 4a6b0a5344
commit 8b3e0fdf01
5 changed files with 79 additions and 13 deletions

View File

@ -4,6 +4,39 @@
# Devlog
## Day 2
Today I explored terrain. I kind of decided to keep exploring emojis for my tileset. Perhaps this is a mistake. Emojis, at least to me, are often "ugly aesthetic." But I use them! One thing that's nice is that they are probably present on most people's systems. And there are already a variety of clear options for the player avatars, enemy "sprites", terrain, objects.
For example, here's a clear trophy like in Indiana Jones and the Temple Doom. Pretty clear that this would lead to the end of the game or be a big prize to get in any game.
```
🏆
```
So if I proceed with emojis for my tileset, I'm thinking about avatars for the player. Does this get selected by the player? Or does the player select a class like in so many other roguelikes, and that determines the avatar? If the player does end up playing this game over days, weeks and months, it's important that they feel connected to their avatar on screen, and I think that would be aided by the player getting to choose their own avatar. Here's some of the options I'm looking at. Notice that these each speak different vocabularies slightly, from the oldschool emoticon smiley and happy faces
```
const avatars = ['👳','👶','🧛','🤺','🕵','👲','🧕','👵','👧','🧔','👸','☹','☺',🤠','@']
```
Ok, so to just get moving, I now have the program choose a random avatar emoji from this array when a new dungeon-game gets created.And I am testing moving using flags. So for example, to move left currently is:
```
node dotd --left
```
or
```
node dotd -l
```
That's probably a bit silly but i'm going with it for now. I'm using yargs to parse the flags in the CLI.
Just had an interesting idea that perhaps the player submits a short program file like 'right right right up up right' so that you have to program your player-robot, and that you submit that and it runs. Would that be interesting? Rather than turn-based? I get too many ideas but should probably just proceed with standard, and then modify later if I don't have a clear goal other than 'wouldn't it be cool if....". Taking a break now for a bit to exercise, answer email, cook dinner, shabbat, and will probably get back to this in the late evening.
## Day 1
i started by creating a an array of arrays (2d array) to 'hold' the level. i looped through it to assign a blank characters, at first a zero, but now a period. it took me some time to figure out how to properly point to a x,y position properly with this method. argh. lots of trial and error and i copy-pasta one line i didn't really understand from stackoverflow but understand what it outputs and worked backwards. actually, here it goes. this is cool. separately, maybe i can revisit making my own processing-derivative drawing parser in ascii. ok ok, that's a later project. anyway, i can now address a grid of text with x,y coordinates. great. proud of myself! lol. i have a grid of periods.
@ -52,3 +85,4 @@ too cheesy? possibly
- [unicode page 437 font](https://github.com/berenddeschouwer/fourthreeseven) to work in linux!
- embedded (copy-pastable) in [this article](https://www.masswerk.at/nowgobang/2020/petscii)
- [petscii to unicode converter](https://style64.org/petscii/)

View File

@ -1,5 +1,8 @@
# TODO
## Bugs
- [ ] after creating dungeon, the player 'jumps' but investigating the gameFile everything looks ok in there. hmmm. it looks like it's not displaying the player where i think they should be located.
- [ ] what's the game mechanic / concept? should be one clear concept
- [.] saveFile should actually save json file (as text) with map and all the tiles in each position:
- [X] player position,

43
dotd.js
View File

@ -8,25 +8,28 @@ const dungeonFile = "dungeonfile.txt";
const gameFile = "gamefile.txt";
//globals
const width = 60;
const width = 20;
const height = 5;
let dungeon;
let player = {"position": {
"x": null,
"y": null,
}
},
"avatar": "@"
};
let parseArgs = () => {
if (argv.new){
console.log('new game');
createDungeon();
choosePlayer();
placePlayer();
} else {
loadDungeon();
loadPlayer();
movePlayer();
}
createTerrain();
}
let loadDungeon = () => {
@ -50,28 +53,28 @@ let loadPlayer = () => {
}
let movePlayer = () => {
if (argv.r){
if (argv.r || argv.right){
if (player.position.x < width-1){
console.log('moved right');
player.position.x++;
} else {
console.log("can't go that way");
}
} else if (argv.l){
} else if (argv.l || argv.left){
if (player.position.x > 0){
console.log('moved left');
player.position.x--;
} else {
console.log("can't go that way");
}
} else if (argv.u){
} else if (argv.u || argv.up){
if (player.position.y>0){
console.log('moved up');
player.position.y--;
} else {
console.log("can't go that way");
}
} else if (argv.d){
} else if (argv.d || argv.down){
if (player.position.y<height-1){
console.log('moved down');
player.position.y++;
@ -82,6 +85,8 @@ let movePlayer = () => {
}
//---------------CREATE DUNGEON -----------------------------------
let createDungeon = () => {
dungeon = Array.from(Array(height), () => new Array(width))
@ -92,6 +97,15 @@ let createDungeon = () => {
}
}
//---------------CREATE PLAYER ----------------------------------
let choosePlayer = () => {
const avatars = ['👳','👶','🧛','🤺','🕵','👲','🧕','👵','👧','🧔','👸','☹','☺','🤠','@']
let chooseAvatar = Math.floor(Math.random() * avatars.length);
player.avatar = avatars[chooseAvatar];
}
let placePlayer = () => {
player.position.x = Math.floor(Math.random()*width)
player.position.y = Math.floor(Math.random()*height)
@ -115,9 +129,24 @@ let dungeonToStrings = () => {
return dungeonStr;
}
let createTerrain = () => {
let forestTerrain = ['🎄', '🌳','🌲']
for (let y = 0; y < height; y++){
for (let x = 0; x < width; x++){
if (dungeon[y][x] === "."){
let whichTerrain = forestTerrain[Math.floor(Math.random()*forestTerrain.length)];
dungeon[y][x] = whichTerrain;
}
}
}
}
let dungeonWithItemsToStrings = () => {
dungeon[player.position.y][player.position.x] = "@"
dungeon[player.position.y][player.position.x] = player.avatar;
let dungeonStr = "";
for (let i = 0; i < height; i++){

View File

@ -1,5 +1,5 @@
............................................................
............................................................
............................................................
............................................................
............................................................
🌳🌲🌳🌳🎄🌳🎄🌲🎄🌳🌳🌳🌳🌲🌲🌲🌲🎄🌲🌳
🌲🎄🌲🌳🌲🎄🎄🎄🎄🌳🎄🌳🎄🎄🌲🎄🌲🌲🌳🌳
🌲🎄🌲🎄🌳🌳🌲🎄🌲🌳🎄🌳🌲🎄🎄🎄🎄🌲🌲🎄
🎄🌲🎄🌳🎄🌳🌲🎄🌳🌲🎄🌳🎄🌳🌳🎄🎄🌲🎄🌲
🌲🌳🎄🌳🌲🌳🎄🌳🎄🌳🌳🌳🌳🎄🌲🎄🌲🎄🎄🎄

View File

@ -1 +1 @@
{"position":{"x":29,"y":2}}
{"position":{"x":8,"y":1},"avatar":"@"}