Log In  

Cart #32754 | 2016-11-25 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

Hi! First off - I'm not in any ways a programmer, I'm hacking together bits and pieces of code, and adding/subtracting stuff from Jelpi. It's basically a reskin, with the enemies taken out, the map and sprites redrawn (eventually) and music rewritten (I'm a musician). I know there's a lot of redundant Jelpi code in there but I think I've deleted about as much as I can without breaking everything.

What I want to do is have a text box open at the bottom of the screen when the player presses X beside the horse. A line of text appears in a black box at the bottom of the screen, disappears and then another appears, etc, until the message is completed. The game is part of a Christmas present for my girlfriend who's in her final year of vet, and it's mad stressful for her.

I was thinking to use a sprite flag but I honestly have no idea how.. any help would be hugely appreciated!

P#32755 2016-11-25 12:41 ( Edited 2016-11-27 12:46)

Even triggering a message standing at the horse sprite would work.

I'm trying to bodge together something that checks the player sprite position and triggers text when it's on the horse sprite but so far getting nowhere..

Something like this?

if (pget(pl.x,pl.y)) == 125 then
print("horse",30,30,11)
end

P#32772 2016-11-26 10:31 ( Edited 2016-11-26 15:40)

Within the Jelpi system, you can make the horse an "actor," and extend Jelpi's collide_event() function for the case where the player and horse are colliding. Give the horse a unique "kind ID" (the first argument to make_actor()), and test for its kind in collide_event(). Look for other calls to make_actor() for examples.

You want the collision to set a variable that the draw routines can see that will be true when the player is near the horse and false when it isn't. If you're in a hurry you can just make this a global variable that _update() sets to false at the beginning, collide_event() sets to true when they're near each other, and _draw() tests and prints a message or whatever. A nicer way to do it would be to set this flag on the horse actor object and make drawing its message part of draw_actor().

The fancy version of dialog prompts would use the "near horse" flag to show an indicator (maybe a speech balloon above the horse) and test for a button press to activate a "dialog mode" for the game. You would store this in the game state (such as another global variable), and have each part of the game change its behavior based on this state. For example, you might continue to animate the clouds, but not update the positions of actors (including the player). Once the player has advanced through all of the dialog, it would reset this state and go back to the game's main mode.

There are a bunch of interesting ways to do fancy dialog stuff, but if you want to go this far, I'd start with just something that print()s a message and listens for a button press when in "dialog mode." Once that's working, you can add features like paging text, animating the letters, etc.

P#32778 2016-11-26 16:42 ( Edited 2016-11-26 21:42)

Edit: - The only real problem now is that text is being written behind the foreground images like so. I've tried putting the speech bubble code in a bunch of different places but can seem to fix this...

Thanks dddaaannn! I got some help from a friend and this is what he came up with last night. He didn't know anything about Lua or Pico 8 so it might not be elegant but it pretty much works! I really have a very basic understanding of programming, I might get somewhere with your suggestions but I might not :)

So speech just appears when the player is at certain coordinates - that's totally fine, I'm not too worried about using the player collision to do this. The only problem is trying to get a prompt working. If I can't get a prompt it'll do though.

In player movement

if(pl.x>=7 and pl.x<=9)
and (pl.y>=20 and pl.y<=28) then
speech_bubble="hoi"
elseif(pl.x>=10 and pl.x<=12) then
speech_bubble="ahoi hoi"
elseif(pl.x>=20 and pl.x<=22)
and (pl.y>=20 and pl.y<=28)
then
speech_bubble="don't look at my butt!!"
else
speech_bubble=""
end

and at the end of draw_game()

if(speech_bubble!="") then
local speech_length = #speech_bubble*3.75
rectfill (60-speech_length/2,63,68+speech_length/2,69,0)
print(speech_bubble,64-speech_length/2,64,8)
end

P#32783 2016-11-27 07:46 ( Edited 2016-11-28 17:11)

[Please log in to post a comment]