Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Clickable Text Links

Author
Message
Smells like Ramen
10
Years of Service
User Offline
Joined: 6th May 2014
Location:
Posted: 6th May 2014 22:56
Hey there,

as a fan of interactive fiction and text adventures I wanted to take a step up from using authoring tools and get into coding.
So far I am quite pleased with AppGameKit, having some knowledge of basic.

Something I cannot get my head around is how I can make some clickable text link to proceed into different areas of the game.

For example there is something written like:
"You are in your room. Next to your door is a giant clock."
I want to have the possibilty of clicking (or tapping on a mobile device) on the words "door" and "giant clock", colored and underlined. Like on a webpage or a game made in twine.

Can this be done in tier1? Or do I need to create a user interface with buttons for every direction.
"You are in your room. Next to your door is a giant clock."
[GO] [DOOR]
[LOOK AT] [GIANT CLOCK]

Thank you very much in advance. Thats kind of a dumb question I fear.
lilpissywilly
AGK Developer
14
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 7th May 2014 20:47
I think I would design an image with the text and then make that a sprite. Then create an invisible sprite to catch the touch in the place you want it.

My hovercraft is full of eels
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 7th May 2014 21:10
If the text objects are their own object then you can test for hits with GetTextHitTest. You could do something like this:
3 text objects
1 - You are in your room. Next to your door is a giant clock.
2 - door (with different color)
3 - giant clock (with different color)
Determine the index of the characters for "door" and "giant clock" in the first text object. SetTextCharColorAlpha to 0 on each character for the words "door" and "giant clock" in the first text object so there aren't weird artifacts. Position text object 2 and 3 with GetTextCharX/Y on the text object 1's "door" and "giant clock". Now that you know the x,y position of your text object 2 and text object 3 as well as their size you can make a 0 texture sprite, size it to the same width of text 2/text 3 and the height of 1-3 pixels, set the color the same to look like a hyperlink and just position it right under the text 2 and text 3 objects. Now test for hits on text 2 and text 3 and respond properly.

I'd use this with caution. From a UI design standpoint this might be quite confusing to players. But if your game is very text oriented then it should be OK. "Better" UI design would be to find the character positions of "door" and "giant clock" and create buttons underneath them so they look like UI elements/buttons. But then again most people should understand when they look like a hyperlink.

This is not a dumb question. I've thought about doing this a lot for Wordspionage because we have a "Message from HQ" dialogue that we use for news announcements. I want to do something like this with it so that we can include hyperlinks in our news items. But I'd also need to add in a bit of parsing for the actual URLs so I haven't done it yet.

Smells like Ramen
10
Years of Service
User Offline
Joined: 6th May 2014
Location:
Posted: 7th May 2014 22:58
Now that sounds promising.

@lilpissywilly (nice username )
That was one of the first ideas I had, but I fear that would be a solution only for a "final" version of a script. As I know myself I will change some phrases here and there.

@Naphier
I think for now this would be more likely my approach. That is the kind of game making logic I need to get into...

Thank you all so far!
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 7th May 2014 23:04 Edited at: 7th May 2014 23:08
i would use drawsprite and paint the chars with a atlas bitmap font.
[] invisible for start / end command. means you can make a command list
which have x1,y1,x2,y2,name. (position means left,top right,bottom)
[ u have x1,y1
] u have x2,y2 and the name
this values u can store in a user defined type and array/list.
also at drawsprite its easy to change colors.

also usefully to make commands inside text that is not printed.
*RGB255,255,064
*LINE
*BLINK
*KURSIV
*BOLD

DrawSprite( iSpriteIndex )
SetSpriteImage ( iSpriteIndex, iImageIndex )
LoadSubImage ( iParentIndex, sImageFilename )

at click / touch, then just look in the list.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
lilpissywilly
AGK Developer
14
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 8th May 2014 08:23
I still think a premade image wins. You can't make underlined text with text commands for instance.

The only reason not to go with an image would be if you want the text to change dynamically at some point in the game.

My hovercraft is full of eels
Smells like Ramen
10
Years of Service
User Offline
Joined: 6th May 2014
Location:
Posted: 9th May 2014 00:18
What is your opinion about using virtual buttons?
I could resize them, set them to the fitting points and make the transparent.
If the user interacts with the word/placement of the button = jump to fitting part of the story/change variable.

Would that make sense?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th May 2014 11:22
virtualbuttons u can have only 12, also size is now width/height together.
alternate u can make u a little editor, draw a rect over a text and
input for a command word/line. save/load this to the szene.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 9th May 2014 22:38
I'd just make some sprite buttons to put under the text at the appropriate locations. You could get pretty advanced with a fairly simple function for that:
(psuedo)
function MakeUItext(sText$ , sWord1$ , sWord2$ , etc.)

parse sText$ by spaces with GetStringToken or mid() commands to find the character index for the beginning and ending of each word.

create a sprite at the location of each word and make sure it has some padding, save the sprite index and the word$ to an array for later reference

endfunction

In such a function you could get more creative and add an image to the "button" sprite, make it out of a few images to have rounded corners, add shadow and highlight sprites, etc, etc.

I personally don't like the virtual buttons. I'm suspect of their stability and I see no advantage to them over using sprite hit testing.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th May 2014 18:27
You could have an underlined version of your font quite easily and use the getTextHit command. Alternatively just manually draw an underline if needed using a sprite. You can get the width of your text object using getTextTotalWidth.
Smells like Ramen
10
Years of Service
User Offline
Joined: 6th May 2014
Location:
Posted: 17th May 2014 14:53
Thank you very much for these different approaches. This really helps me getting into the logic of programming and specific troubleshooting!
Smells like Ramen
10
Years of Service
User Offline
Joined: 6th May 2014
Location:
Posted: 29th May 2014 19:58
Now I have a new problem.
I use the getTextHit command and GetPointerPressed to check if the text got clicked. Then I tell the game to GoSub "next Part in the game". There the string "Introtext" will be altered to fit the room.
My problem is, that the game jumps across many different rooms because the action menu got clicked already.



What am I doing wrong ?
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 29th May 2014 20:03
Call sync() after GetPointerPressed = 1 check that will clear it out. GtPointerPressed will return 1 after a pointer press until the next sync call.

Smells like Ramen
10
Years of Service
User Offline
Joined: 6th May 2014
Location:
Posted: 29th May 2014 20:29
Okay, I changed it to:



Works like a charme! Thank you very much.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 30th May 2014 04:31
And using Gosub in that way is not a good idea.

You are adding things to the call stack and never doing a 'Return' from the sub.

The way you are using it, you should use 'GoTo', which does not expect to be returned from.

Cheers,
Ancient Lady
Smells like Ramen
10
Years of Service
User Offline
Joined: 6th May 2014
Location:
Posted: 30th May 2014 19:12
So Gosub would be better for things like "Look around" -> Further Description, wait for action, return I guess? At least at that context.
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 31st May 2014 08:56
Functions are better than using Gosub. For example, you can have local variables, which cuts down the number of globals used.

-- Jim - When is there going to be a release?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Jun 2014 01:22
I agree with JimHawkins that functions are much better than Gosubs.

Cheers,
Ancient Lady
Smells like Ramen
10
Years of Service
User Offline
Joined: 6th May 2014
Location:
Posted: 1st Jun 2014 12:00
So in programming logic that would be:
Define rooms and actions as function.
Do action or change room -> start function?

Login to post a reply

Server time is: 2024-11-25 05:51:24
Your offset time is: 2024-11-25 05:51:24