[Plugin] AirConsole - local multiplayer for your game

Post your completed addons to share with the community

Post » Fri Oct 21, 2016 8:51 pm

I need help please. I do not get to operate the controller. The game loads on the computer screen, however I copied the following code in a file controller.html and the driver does not appear in the device:

<html>
<head>
<!--<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>-->
<meta name="viewport" content="user-scalable=yes"/>
<style type="text/css">
html, body {
height: 100%;
overflow: hidden;
}
body {
background-color: #222;
}
button {
margin-bottom: 1px;
width: 48%;
height: 48%;
border: 0;
box-sizing: border-box;
font-size: 40px;
color: #FFFFFF;
background-color: #333333;
outline: none;
}
</style>
</head>
<body>
<div style="width:100%;float:left;">
<button id="leftup">UP</button>
<button id="rightup">UP</button>
</div>
<body>
<div style="width:100%">
<button id="leftdown">DOWN</button>
<button id="rightdown">DOWN</button>
</div>


<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="https://www.airconsole.com/api/airconsole-1.3.0.js"></script>
<script type="text/javascript">

var air_console = new AirConsole();

// Let the screen know we are here
var sendHandshake = function() {
air_console.message(AirConsole.SCREEN, {
handshake: true
});
};

air_console.onReady = function() {
sendHandshake();
};

air_console.onMessage = function(device_id, data) {
if (data.handshake) {
sendHandshake();
}
};

var down_event = isMobile() ? 'touchstart' : 'mousedown';
var up_event = isMobile() ? 'touchend' : 'mouseup';

$("#leftup").on(down_event, function () {
air_console.message(AirConsole.SCREEN, {
message: 'leftup'
});
});

$("#leftdown").on(down_event, function () {
air_console.message(AirConsole.SCREEN, {
message: 'leftdown'
});
});

$("#leftup").on(up_event, function () {
air_console.message(AirConsole.SCREEN, {
message: 'leftstop'
});
});

$("#leftdown").on(up_event, function () {
air_console.message(AirConsole.SCREEN, {
message: 'leftstop'
});
});

$("#rightup").on(down_event, function () {
air_console.message(AirConsole.SCREEN, {
message: 'rightup'
});
});

$("#rightdown").on(down_event, function () {
air_console.message(AirConsole.SCREEN, {
message: 'rightdown'
});
});

$("#rightup").on(up_event, function () {
air_console.message(AirConsole.SCREEN, {
message: 'rightstop'
});
});

$("#rightdown").on(up_event, function () {
air_console.message(AirConsole.SCREEN, {
message: 'rightstop'
});
});

/**
* Returns true if device is a mobile device
* @return {Boolean}
*/
function isMobile() {
if (navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/iPod/i) ||
navigator.userAgent.match(/BlackBerry/i) ||
navigator.userAgent.match(/Windows Phone/i) ||
navigator.userAgent.match(/Opera Mini/i) ||
navigator.userAgent.match(/IEMobile/i)) {
return true;
} else {
return false;
}
};
</script>
</body>
</html>


How do I have to create the driver?

Thank you.
B
10
S
2
Posts: 205
Reputation: 1,619

Post » Tue Oct 25, 2016 12:12 pm

Message: FraConsole can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
@iherwis
Sorry, you will have to code a little bit if you want to make a controller.
In the same directory of your web-exported construct2 files, create a controller.html
There are some examples at: https://github.com/AirConsole/airconsole-controls

@DatapawWolf
the plugin is currently being updated and showing ads will follow soon
B
7
S
1
Posts: 15
Reputation: 470

Post » Tue Oct 25, 2016 12:14 pm

@amariscal I don't understand what you mean with "driver". Can you please elaborate?!
B
7
S
1
Posts: 15
Reputation: 470

Post » Fri Nov 18, 2016 3:03 am

@FraConsole,

Kudos to the AirConsole team for pulling everything together! My students are looking forward to entering the student competition in December, and I just received the blog post about requiring the 1.6 API so that people don't have to buy a premium account to play our game. I was hoping we could start pulling everything together next week (Thanksgiving here in the US) so that we could do play testing and final artwork. Along with this we were hoping to not have to worry about changing the code after next week.

Any idea when the new version of the plugin will be available that is compliant with the 1.6 API? Any chance it will be by next week? If not, its not the end of the world, but we were hoping to get everything wrapped up before the December 15th deadline.

In any case, here is what we have so far. Thanks to @QuaziGNRLnose for the incredible Q3D plugin, and the AirConsole team for making an awesome way to play multiplayer!

https://www.airconsole.com/#https://dl. ... irconsole/

PS - Join with as many devices as you can, wait for the 3-minute timer to run out, and watch the AI take over. We aren't planning to include any limits on the number of devices that can join the game. So far we have tried it with a room full of 15 robotics club team members. Way better than a 4-player console game -- Total Robot Mayhem! :)
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
52
S
17
G
26
Posts: 436
Reputation: 18,092

Post » Tue Nov 22, 2016 12:38 pm

The AirConsole plugin got updated to API 1.6.0 adding ads support, AirConsole team just merged my Github pull request.

Don't forget that implementing ads in your games is due for February 2017

Added in version 1.4.4
  • Update to API 1.6.0 don't forget to update your controller.html api link!
  • New conditions:
    • OnAdComplete - Trigger - Triggered when showing ads is finished - Use it to unmute your sounds per exemple
    • OnPremium - Trigger - Triggered when a premium device joins or a device gets premium - Use for special cases for premium, premium don't get ads per exemple
  • New actions:
    • ShowAd - Displays adds on screen and controllers. Triggers OnAdComplete when done
  • New expressions:
    • IsPremiumJoin - Returns 1 if the last controller that joined is premium, else 0
    • IsPremiumMessage - Returns 1 if the last controller that sent a message is premium, else 0
    • IsPremium(deviceId) - Returns 1 if the deviceId is premium, else 0
  • Reordering expressions by using categories

Check it out on Github:

Official AirConsole repo: https://github.com/AirConsole/airconsole-construct2
My fork: https://github.com/Psychokiller1888/airconsole-construct2

Feel free to contact me for additions, missing parts etc etc
Last edited by Psychokiller1888 on Fri Nov 25, 2016 11:59 am, edited 3 times in total.
B
36
S
12
G
3
Posts: 239
Reputation: 4,557

Post » Tue Nov 22, 2016 1:01 pm

Awesome work, thanks @Psychokiller1888 ;)
ImageImageImage
B
33
S
19
G
82
Posts: 1,039
Reputation: 46,257

Post » Sat Dec 03, 2016 7:49 pm

Version 1.4.5 available on my fork https://github.com/Psychokiller1888/air ... construct2

Adding NavigateHome : Requests all devices to open AirConsole store
Adding NavigateTo: Requests all devices to load a game by url
B
36
S
12
G
3
Posts: 239
Reputation: 4,557

Post » Fri Dec 09, 2016 7:37 pm

Version 1.4.5 got merged on official sources, but I must apology to all users, I messed up isPremiumJoin and isPremiumMessage by misspelling the variables (and not being at home using my editor I did not notice). Just saw that today when starting the whole in PhpStorm that warned me about unsued variables. A pull request for fix is waiting, for those that can't wait, the fix is available on my repo

EDIT
For clarity, this does just touch expressions and not triggers/conditions
B
36
S
12
G
3
Posts: 239
Reputation: 4,557

Post » Sat Dec 10, 2016 6:41 am

I commited, on my repo, a new branch that adds support for real messages with complex structures as the controller generator does generate

https://github.com/Psychokiller1888/air ... MessageKey

If anybody wants to try it out and maybe return the experience I'd be glad. Be aware this is experimental and subject to changes, that's why it's commited on a separate branch!

This allows, per exemple, messages sent like

Code: Select all
airConsole.message(AirConsole.SCREEN, {
  rejoin: "12345",
  name: "Psycho",
  age: "hmmm",
  country: "Switzerland",
  controls: {
    dpad: true,
    buttons: true,
    swipe: false,
    joystick: false
  }
});


It is recursive. Getting the data is made through AirConsole.GetMessageProperties. Load a C2Dictionary with it

Image
B
36
S
12
G
3
Posts: 239
Reputation: 4,557

Post » Thu Dec 29, 2016 9:28 am

My pull request just got merged and introduces, in my opinion, more advanced functions to the plugin. Let me explain you the changes:

AirConsole version 1.4.6
  • Conditions
    • OnMessageKey - Trigger - Depracated. This method wasn't really doing what it should have be doing. This is flagged as deprecated, so you cannot use it anymore but your projects using it should load just fine and still work
    • OnMessageKey - Trigger - Triggered when any message comes in with a different key than 'message'
    • OnMessageKeyIs - Trigger - Triggered when a message comes in with only one property and that property is what you are waiting for
    • OnMessageKeysContain - Trigger - Triggered when a message comes in and its properties contain the specified key
  • Expressions
    • GetMessageProperties - Returns all the properties that were sent in the last message in the form of a C2Dictionary
    • GetMessageProperty - Returns the specified property value
    • GetMessagePropertiesCount - Returns the number of properties set in the last message
    • IsMessagePropertySet - Returns 1 if the last message had the specified property set, else 0

This might get a bit confusing, so here is a link to the pull request and all the screenshots I did back then: https://github.com/AirConsole/airconsol ... t2/pull/18

Some images
Image
Image
Image
Image
Image
Image
Image


Most important is that GetMessageProperties is full recursive and now supports the actual controller generator for AirConsole as complexe messages are now supported. So there is no problem sending messages like:

Code: Select all
airConsole.message(AirConsole.SCREEN, {
  dpad: true,
  swipe: false,
  nickname: "Psycho",
  options: {
    sound: "mute",
    vfx: 10,
    privacy: {
      world: true,
      region: true,
      city: false,
    }
  }
});


are easily captured and read by something like (make 'subList' be 'options' and 'subSubList' be 'privacy' ;) ):
Image

As always, download the plugin on the official chanel:
https://github.com/AirConsole/airconsole-construct2

Or on my repo if you want access to my latest additions not yet merged:
https://github.com/Psychokiller1888/air ... construct2

Coming next
  • Complete support for highscore and reading data
  • Persistant data support

Happy new year to you all!

And again, I'm not working for N-Dreams, I'm just coding for fun and they do appear to appreciate that I pull request all these changes. Still, you can pm me if you have any questions about the plugin.
B
36
S
12
G
3
Posts: 239
Reputation: 4,557

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 3 guests