Log In  

Cart #hametawisu-7 | 2022-01-06 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
8

This is my first pico-8 game, feedback welcome.

Things I want to add/improve (that I don't necessarily know how to do):

  • m̶a̶k̶e̶ ̶t̶h̶e̶ ̶h̶u̶d̶ ̶f̶o̶l̶l̶o̶w̶ ̶t̶h̶e̶ ̶p̶l̶a̶y̶e̶r̶ ̶t̶o̶ ̶a̶ ̶n̶e̶w̶ ̶r̶o̶o̶m̶ ̶(̶i̶'̶m̶ ̶h̶a̶l̶f̶ ̶w̶a̶y̶ ̶t̶h̶e̶r̶e̶ ̶j̶u̶s̶t̶ ̶n̶o̶t̶ ̶s̶u̶r̶e̶ ̶w̶h̶a̶t̶ ̶e̶l̶s̶e̶ ̶t̶o̶ ̶d̶o̶!̶)̶

  • enemies that move left to right and up and down (half working)

  • knock back when taking damage on spikes or lava when stepped on (currently just contact and take damage)

  • print the value of an object next to it when buying from the merchant

  • ability to swing a sword and attack

  • change player direction when moving and moving animations

  • m̶u̶s̶i̶c̶ ̶a̶n̶d̶ ̶m̶o̶r̶e̶ ̶s̶o̶u̶n̶d̶ ̶e̶f̶f̶e̶c̶t̶s̶ ̶(̶d̶o̶n̶'̶t̶ ̶k̶n̶o̶w̶ ̶h̶o̶w̶ ̶t̶o̶ ̶p̶r̶o̶g̶r̶a̶m̶ ̶t̶h̶e̶ ̶m̶u̶s̶i̶c̶ ̶i̶n̶)̶

  • a̶d̶d̶ ̶i̶n̶ ̶c̶h̶e̶c̶k̶p̶o̶i̶n̶t̶s̶ ̶a̶f̶t̶e̶r̶ ̶e̶a̶c̶h̶ ̶r̶o̶o̶m̶ ̶(̶s̶t̶r̶u̶g̶g̶l̶i̶n̶g̶ ̶t̶o̶ ̶s̶e̶t̶ ̶a̶n̶d̶ ̶r̶e̶c̶a̶l̶l̶ ̶t̶h̶e̶ ̶X̶,̶y̶ ̶o̶f̶ ̶t̶h̶e̶ ̶c̶h̶e̶c̶k̶p̶o̶i̶n̶t̶ ̶w̶h̶e̶n̶ ̶p̶l̶a̶y̶e̶r̶ ̶d̶i̶e̶s̶)̶

  • a̶d̶d̶ ̶a̶ ̶t̶i̶t̶l̶e̶ ̶s̶c̶r̶e̶e̶n̶ ̶a̶n̶d̶ ̶s̶p̶l̶a̶s̶h̶ ̶s̶c̶r̶e̶e̶n̶ ̶(̶n̶o̶ ̶c̶l̶u̶e̶ ̶h̶o̶w̶ ̶t̶o̶ ̶d̶o̶!̶)̶

  • equipment that changes stats

  • pause screen that displays equipment information

  • mini tarot game at start that lets you pick a card to give items and stats/

Any help or advice on improving this would be much appreciated

thank you to the community for giving me lots of help learning the basics of lua and helping me realise a new hobby :)

much thanks to @remcode for help coding and fixing the number puzzle!

̶P̶.̶s̶.̶ ̶c̶a̶n̶'̶t̶ ̶f̶i̶x̶ ̶t̶h̶e̶ ̶b̶u̶g̶g̶e̶d̶ ̶s̶e̶c̶o̶n̶d̶ ̶l̶e̶v̶e̶l̶ ̶c̶u̶r̶r̶e̶n̶t̶l̶y̶,̶ ̶u̶s̶e̶ ̶d̶i̶a̶g̶o̶n̶a̶l̶ ̶b̶u̶t̶t̶o̶n̶s̶ ̶:̶)̶

previous versions:

Cart #hametawisu-4 | 2022-01-02 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
8


Cart #hametawisu-3 | 2022-01-02 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
8


Cart #hametawisu-1 | 2022-01-01 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
8


Cart #hametawisu-0 | 2021-12-31 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
8


Cart #frogbite-0 | 2021-12-31 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
8


P#103918 2021-12-31 16:30 ( Edited 2022-01-06 16:02)

1

another suggestion: I walked on spikes and expected that I could take damage and cross over, but I only took repeated damage. it would be nice if I could decide to sacrifice health to go faster, or alternatively the drawing should be bigger so that it makes sense that I can’t walk over it :)

for the hud question: keep your code that calls camera, draws map and player, but add a call to 'camera()' before you draw the hud. it will reset the camera, so drawing functions that follow will be on screen.

P#103932 2021-12-31 18:16
1

I can't seem to move forward in the second room. I'm guessing the note is blocking me.

P#103947 2021-12-31 20:37
1

I remember struggling for hours to make the UI follow the camera as I made my first game.. There might be a better/more efficient way to do this and maybe you already figured it out, but one way of doing this is to add camera coordinate to every UI display like this

 spr(p.hsprite,mapx*8+2,mapy*8+1)

I guess it's up to you if you want to do a post-hit invincibility using a timer or send the player back to the last checkpoint (once you implement it).

ps. and can confirm I can't get past the second room entrance because the message is blocking

P#103958 2021-12-31 21:38 ( Edited 2021-12-31 21:40)

thanks @merwok and @katiusza have made a moving hud now. amazing feedback thankyou :)

P#104014 2022-01-01 12:24
1

It's going well, and quite enjoyable ...

But I crashed it in the top left of this screen - at the very top, which is no longer visible, but not quite the most left:

P#104105 2022-01-02 13:11 ( Edited 2022-01-02 13:12)

sorry thats part of some buggy number puzzle, didnt realise i left the door in there! ay advice would be appreciated :)

P#104107 2022-01-02 13:37
1

@yorrellew

I was interested in the number puzzle, so I went through the code ...
... and ended up with a debug version.

[Cartridge removed from BBS for reason given in next paragraph - I am taking yorrellew's next post as an indication that it has been downloaded.]

I'll remove it from the bulletin board once you have indicated that you have either downloaded it or don't need it. I wouldn't want to leave a debug version with invincibility etc turned on, on the bulletin board.

Feel free to use all, some, or none of it. Of the things you indicated in your original post that you would like to improve/add, it only adds in the checkpoint.

If you just want to use it for advice, just look through number_puzzle, checkp, and restore and the other bits of the code relevant to them.

checkpoint

You might not want any of them in the way I've coded them - for example, checkp and restore are set up in such a way that all the player state (from the point at which they encountered the last checkpoint) is restored except hearts, which might not be what you wanted. It could just instead do:

 checkpoint={x=p.x,y=p.y}

Then restore could do:

 p.x=checkpoint.x
 p.y=checkpoint.y

Which would mean that anything (keys) the player has collected since the checkpoint would be kept when they are restored back to the checkpoint.

Details

It enables checkpoints and fixes the number puzzle.

And it also makes the player almost invincible and able to walk through walls. And adds a function in the pause menu so you can still test the checkpoint even though you're almost invincible. The invincibility and walking through walls were coded for debug so I could get to the puzzle room quicker.

The single alteration to the map is the addition of a checkpoint flag near the start, for testing it.

Finding the code I have altered

Search the code with ctrl+f for remcode, then use ctrl+h to continue the search throughout the other tabs. There are about 18 places I changed code, some to enable invincibility etc, and others to improve number_puzzle. I left a comment at each.

To identify the points where I have changed things for debug, just search in a similar way for debug, or alternatively in _init set debug to false.

Note - I've only tested it with debug set to true. You should also test it with debug set to false (or all debug code removed) to make sure it still works as intended.

P#104115 2022-01-02 16:56 ( Edited 2022-01-03 14:50)

@remcode
Wow this is amazing thank you! I'll be sure to try and understand some of the stuff you've added and try and implement it myself so I can try and learn from it :)

P#104185 2022-01-03 10:46

@remcode
I've been fiddling with the number puzzle and got it working perfectly.
Before it was deleting the tile from the number table and then it was shifting every tile along because then the tile and value would not line up.

I've added the following instead:

for i=1,#number do
   if number[i]==tile then
    p.total+=i
    p.count=i
   end
  end
add(number,0,p.count)
del(number,tile)
...

this logs i index as the value and reuses it to indicate where to add the nil value.

took a while but I learnt a lot from it!

P#104335 2022-01-05 14:03

@yorrellew

Well spotted!

Sorry about that.

I had uploaded a version of it that fixed that, and added a comment in my original post to that effect - but I removed the comment when I removed the program. I guess you downloaded the first version I uploaded, and as I didn't make a new post (only edited the existing post) there was nothing to alert you to the fact that I had corrected a bug.

I'm glad you managed to spot it and correct it for yourself.

And I'm glad you learnt a lot from it too. :)

P#104346 2022-01-05 15:51 ( Edited 2022-01-05 15:54)

@yorrellew

At the moment the way I coded the restore, it doesn't restore any of the collectables (not all restores need to restore collectables), and the player loses collected collectables. This could become problematic in the game, because a player can collect keys, lose a life on the spikes, be restored without the keys, and the keys are gone. This can trap the player in an area, which I presume isn't the intention.

Having made that presumption, and as it's the code I wrote that isn't doing quite enough, here is some advice on ways you could handle it. As before you're welcome to use some, all, or none of it, depending on what you want for your game.


There are a number of ways it can be handled to make sure the player doesn't get trapped. One would be, in the checkp() function, just to copy their .x and .y into checkpoint as I mentioned a couple of posts ago, which I think was your original intention.

Another way to handle it would be to have the restore function note the number of keys, then overwrite the restored values.

function restore(new_hearts_amount)
 if (not checkpoint) then
  p.hearts=new_hearts_amount
  return
 end 

 local keys=p.keys
 local bkeys=p.bkeys
 local rkeys=p.rkeys

 checkpoint.hearts=3
 for k,v in pairs(checkpoint) do
  p[k]=v
 end

 p.keys=keys
 p.bkeys=bkeys
 p.rkeys=rkeys
end

Another alternative would be: in checkp() iterate over the map and make a table that holds the locations and sprite number of all keys and the closed doors that the keys open, at the time the checkpoint is passed, then when restore() is called (as well as restoring the player's previous x and y), iterate over that table and use mset to put them all back where they were.

Some games do one thing, some another - it's a design choice.


On the probability that for k,v in pairs() needs to be explained (or it might help someone else who might be unfamiliar with this type of loop):

(Hidden due to length; click show.)


I copied (and restored) everything in the player table p originally because I wasn't familiar with the code, and rather than go through all the variables and try to work out how relevant they were, the simple solution was to copy everything and see what happened. The copy of everything I did is probably a heavy-handed solution - if I had been familiar with the actual items in the table, I could have picked carefully which ones to copy and restore. I haven't changed the copy I've written in checkp() in what I've written in this post because I still don't know what all of the items in the p table do, but I can see now that some of the items with 'key' in the name (not all of them) are particularly significant to the above.

The copy and restore of all the information happens in the loops which I wrote like this:

for k,v in pairs( ...

This just sets a loop up over whichever table is in the brackets after pairs, and puts every one of the named items in the table into the loop variables k and v (which stand for 'key' and 'value', where 'key' is the item name in the table, and 'value' is the value that item name refers to), such that:

 checkpoint={}
 for k,v in pairs(p) do
  checkpoint[k]=v
 end

Is a short way of writing:

 checkpoint={}
 checkpoint.x=p.x
 checkpoint.y=p.y
 checkpoint.sprite=p.sprite
 checkpoint.keys=p.keys
 checkpoint.bkeys=p.bkeys
 checkpoint.rkeys=p.rkeys
 checkpoint.skeys=p.skeys
 checkpoint.gold=p.gold
 checkpoint.dmg=p.dmg
 checkpoint.hearts=p.hearts
 checkpoint.hsprite=p.hsprite
 checkpoint.hsprite2=p.hsprite2
 checkpoint.bhsprite=p.bhsprite
 checkpoint.keyssp=p.keyssp
 checkpoint.keysspb=p.keysspb
 checkpoint.keysspr=p.keysspr
 checkpoint.keyssps=p.keyssps
 checkpoint.goldspr=p.goldspr
 checkpoint.sword=p.sword
 checkpoint.price=p.price
 checkpoint.total=p.total
 checkpoint.count=p.count

And will also copy any other values from the p table that I might have missed.

So the first values (if it was taken in order) for k,v would be:

k="x" v=p.x

Such that if p.x was 8, then the loop variable v would hold the value 8.

Then inside the loop, on that particular iteration:

  checkpoint[k]=v

Resolves to:

  checkpoint["x"]=8

Which is another way of writing:

  checkpoint.x=8

So, in checkp(), if you only wanted some of the information, the for k,v in pairs(p) loop could be replaced by:

 checkpoint={}
 checkpoint.x=p.x
 checkpoint.y=p.y
 checkpoint.keys=p.keys
 checkpoint.bkeys=p.bkeys
 checkpoint.rkeys=p.rkeys

And any other similar pairs that you might want to copy across (gold, for example).

P#104457 2022-01-07 10:38 ( Edited 2022-01-07 11:05)

i lost all my keys when i died, couldnt beat the first level

P#134060 2023-09-08 16:19

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 08:23:05 | 0.079s | Q:47