HTML5 Blackjack w/REST API Sample

Bringing your stacks to the web

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bhall2001
Posts: 107
Joined: Thu Oct 30, 2014 3:54 pm
Location: Manchester, NH

HTML5 Blackjack w/REST API Sample

Post by bhall2001 » Sat Nov 26, 2016 7:05 pm

The new do as JavaScript command adds a whole WORLD of opportunity. I've put together a demonstration of an LC stack making external Javascript calls.

The stack is Blackjack. The decks and cards are determined from a REST API call to deckofcardsapi.com. The API calls are Javascript functions. The Livecode stack calls this functions to shuffle the deck and deal out cards.

The game play is pretty good although there is a bug with Aces (I'm working on it). I'm also going to add some other calls out to the HTML page to further demonstrate the JavaScript capabilities. The important item of note is that a Livecode HTML5 stack is making a call to a Javascript function that is calling a REST API on a remote server. COOL!

http://bobhall.net/blackjack/index.html

God, I hope I don't break my server ;-)

Let me know what you think,
Bob

peter-b
Posts: 182
Joined: Thu Nov 20, 2014 2:14 pm
Location: LiveCode Ltd.

Re: HTML5 Blackjack w/REST API Sample

Post by peter-b » Mon Nov 28, 2016 11:43 am

This is a fantastic demo of what can be done with LiveCode HTML5, Bob! Thank you for sharing it with us. :D
LiveCode Open Source Team — @PeterTBBrett — peter.brett@livecode.com

AndyP
Posts: 614
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Re: HTML5 Blackjack w/REST API Sample

Post by AndyP » Mon Nov 28, 2016 1:39 pm

Excellent example..thanks.
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

bhall2001
Posts: 107
Joined: Thu Oct 30, 2014 3:54 pm
Location: Manchester, NH

Re: HTML5 Blackjack w/REST API Sample

Post by bhall2001 » Mon Nov 28, 2016 9:01 pm

Thanks peter-b and AndyP!

I've updated the demonstration to fix the Ace's bug.

To Peter (or whomever at Livecode Central), THANK YOU for adding this ability to get to Javascript. For me, I was missing the goes-inta and goes-outa capability of HTML5 and now that is SOLVED!.

I'm sure you've already got this but it would be really nice to send a SIMPLE message into the Livecode container (no data) from Javascript.

Code: Select all

livecodeObject.sendMessage("someDataIsReady");
My hope is that no data makes it an easier thing to do. I've seen examples of Javascript being able to call functions of other languages running in a container in the Browser so I'm hoping this might be doable and, who knows, maybe, Trivial :)

Sending a message back to Livecode not only do we get asynchronous GET/POST but also some other cool things (WebSockets...).

Thanks again!
Bob

peter-b
Posts: 182
Joined: Thu Nov 20, 2014 2:14 pm
Location: LiveCode Ltd.

Re: HTML5 Blackjack w/REST API Sample

Post by peter-b » Tue Nov 29, 2016 10:26 am

Adding the ability to send messages back into LiveCode is something we're currently hoping to get working in December or January. It will be a bit more involved than the "do as JavaScript" feature. I made some comments about it here: https://www.mail-archive.com/use-liveco ... 80603.html
LiveCode Open Source Team — @PeterTBBrett — peter.brett@livecode.com

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: HTML5 Blackjack w/REST API Sample

Post by [-hh] » Tue Nov 29, 2016 12:07 pm

Hi Bob.

This is a really great example for a "direct connection" from/to a HTML5 standalone, also solved in an elegant way!

'Newcomers' to HTML5 standalone building perhaps would appreciate a few lines of explanation about 'the essentials' of the connection, independent of details of the game.

Would you mind to add such a post here?
shiftLock happens

bhall2001
Posts: 107
Joined: Thu Oct 30, 2014 3:54 pm
Location: Manchester, NH

Re: HTML5 Blackjack w/REST API Sample

Post by bhall2001 » Tue Nov 29, 2016 3:33 pm

Great suggestion [-hh]. I will work on it today and get it posted.

Bob

UKMC
Posts: 50
Joined: Sun Jan 08, 2017 12:01 pm

Re: HTML5 Blackjack w/REST API Sample

Post by UKMC » Mon Feb 27, 2017 3:32 pm

Hi Bob,

I'm an absolute novice in these server affairs,
I hope to get an answer for you;

Is the UserInterface (UI) which is displayed in the browser a LC-HTML5-standalone or is it a LC-stack which is "mirrored" into the webpage ?

I'm looking for a solution to let the LC-stack run on the server and it's UI is mirrored in a standard web browser.

Do you know any product who allows something like this ?

Best regards


Ulrich
bhall2001 wrote:Great suggestion [-hh]. I will work on it today and get it posted.

Bob

keliko
Posts: 85
Joined: Thu Aug 01, 2019 8:15 am

Re: HTML5 Blackjack w/REST API Sample

Post by keliko » Wed Nov 13, 2019 3:51 am

thanks. :D

Post Reply

Return to “HTML5”