Page 1 of 1

HTML5 Blackjack w/REST API Sample

Posted: Sat Nov 26, 2016 7:05 pm
by bhall2001
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

Re: HTML5 Blackjack w/REST API Sample

Posted: Mon Nov 28, 2016 11:43 am
by peter-b
This is a fantastic demo of what can be done with LiveCode HTML5, Bob! Thank you for sharing it with us. :D

Re: HTML5 Blackjack w/REST API Sample

Posted: Mon Nov 28, 2016 1:39 pm
by AndyP
Excellent example..thanks.

Re: HTML5 Blackjack w/REST API Sample

Posted: Mon Nov 28, 2016 9:01 pm
by bhall2001
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

Re: HTML5 Blackjack w/REST API Sample

Posted: Tue Nov 29, 2016 10:26 am
by peter-b
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

Re: HTML5 Blackjack w/REST API Sample

Posted: Tue Nov 29, 2016 12:07 pm
by [-hh]
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?

Re: HTML5 Blackjack w/REST API Sample

Posted: Tue Nov 29, 2016 3:33 pm
by bhall2001
Great suggestion [-hh]. I will work on it today and get it posted.

Bob

Re: HTML5 Blackjack w/REST API Sample

Posted: Mon Feb 27, 2017 3:32 pm
by UKMC
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

Re: HTML5 Blackjack w/REST API Sample

Posted: Wed Nov 13, 2019 3:51 am
by keliko
thanks. :D