jhice's Forum Posts

  • Thanks Kyatric.

    I won't be sad if you don't post it, if you think it's not a "frequently" question (and you know it better than me)

    Just wanted to contribute to a problem I faced. Your solution is of course good in the scope of C2, but needs to manage 3 variables, what I wanted to avoid (lazyness ^^). Anyway, I found my answer searching the forum.

  • lennaerthohe.nl/TankRacer/index.html TankRacer

    Its based on socket.io.

    I build this in december somewhere.

    The Battle arenas work nice.

    Regular multiplayer was giving some hassle with positioning.

    But since then webrtc was making its way to construct 2, so I figured I wait it out.

    Tried it, but alone ^^ Will try it with a friend...

  • Here's an example why it is useful to know the color formula (where wsColor is a number value) :

  • : see the other post. Probably we can change de title of the question, but IMHO this conversion is still useful if we want to use direct color value without using rgb() (or without the possibility to use it).

    Here's an example why it is useful to know the color formula (where wsColor is a number value) :

  • Kyatric : the fact is that I have colors coming from a server, and wanted to evaluate "rgb(0,64,255)" but it's not possible (see here : scirra.com/forum/viewtopic.php

    So I searched how to convert rgb to C2 internal value, to send it directly from my server and use it as is in the code. And the formula is not wrriten in the manual.

    (dont know if we're on the same page ^^)

  • I found the color formula here : scirra.com/forum/viewtopic.php and submitted it in the "How do I..." page (where I looked first ^^).

    Can you give an example of JS execution in the browser ? (just for information).

    Thanks

    Amazing community and software

  • Hi, great page, thanks !

    New tip :

    Category: General/Misc

    Question: Convert rgb(r,g,b) to C2 internal color value

    Link to the answer: https://www.scirra.com/forum/viewtopic.php?f=160&t=85796

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Up ^^

    Thanks for the tip.

    For lazy people, a simple PHP script to convert color (up to you to convert it in any other language :p) :

    <?php
    if($_POST) {
    	$r = $_POST['r'];
    	$g = $_POST['g'];
    	$b = $_POST['b'];
    	$converted = $r + $g*256 + $b*65536;
    	echo "rgb($r,$g,$b) => $converted";
    }
    ?>
    
    <form action="" method="post">
    	<p>R <input type="text" name="r" /></p>
    	<p>G <input type="text" name="g" /></p>
    	<p>B <input type="text" name="b" /></p>
    	<p><input type="submit" value="Convert" /></p>
    </form>
    
    <p>Source : <a href="https://www.scirra.com/forum/viewtopic.php?f=160&t=85796&p=687135">Scirra forum : Theme Color convertion</a>[/code:li0srjn9]
  • Ok I see. I will go on the second option (result of color), but cant see it at runtime. I have the free version of C2, in the debug panel color does not appear. Or do I have to look elsewhere ?

    Thanks

    EDIT : found this topic, diggin it scirra.com/forum/viewtopic.php

    PS : coming from AS and PHP, the "eval()" function is useful although it is sometimes a bad practice, perhaps that's why C2 doesn't provide it ^^

  • Hi lennaert

    Nice to hear some news from you on this topic of networking. Do you have "public demo" on your VPS than we can try together ?

    Do you have multiplayer games playable online ?

    I've got a little dedicated server (10€ a month too) where I host a website, but as soon as I've got something working, I will put it online.

    By the way, with the "ws" WebSocket server for node js, I managed to use the WS plug-in of C2 and communicate between clients \o/ I'll certainly make a tutorial out of this, as it could interest beginners in networking.

  • Hi,

    I have a string coming from a server I want to use as an expression :

    [TEXT] Set font color to : "rgb(0,64,255)"

    The problem is C2 refuse my string, asking me a number. I could'nt find answser in the actual posts (found answers with string concatenation but it is still a string).

    Is there something like eval("rgb(0,64,255)") ?

    Thanks.

  • Back,

    I wonder if we should use "Server" or "WebSocket" ... Need to go further in this.

  • <div class="post-censorship-notice">jhice can only post plain text URLS until they have 500 rep. 3 URLS modified. Why?</div>

    It works like a charm <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile"> At least the very basics.

    I managed to create a server with node (http://nodejs.org/) + ws (https://github.com/einaros/ws).

    For those interested in doing their first WS connection with the WebSocket plug-in :

    1. Create a server as shown on the "ws" page (after installing node.js and ws) :

    var WebSocketServer = require('ws').Server, wss = new WebSocketServer({port: 1337});
    wss.on('connection', function(ws) {
        ws.on('message', function(message) {
            console.log('received: %s', message);
        });
        ws.send('something');
    });[/code:nu8sgysw]
    Run in a a command window "node server.js" (if you saved the file as "server.js").
    
    [b]2. Create a blank project in C2 (with a debug text), and assign a few events :[/b]
    
    [url=http://i.imgur.com/sPH1RvG.png][img="http://i.imgur.com/sPH1RvGl.png"][/url]
    
    Preview it, you should see random numbers sent from the HTML page to the WS server (in the command window).
    This is just for testing (ie sending a message on every tick).
    
    [b]Here's the capx if needed :[/b] http://www.fidfaenor.com/jhice/websocket-test.capx
    
    Hope this helps turn-based desires <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">
    
    PS : thanks to lennaert for helping this post live ^^
  • Hi Ashley,

    Thank for this explanation. Indeed socket.io is never mentionned in the C2 WS manual page...

    I was looking right now in the plug-in from SgtConti's tuto, and see this is a big hack of the C2 plug-in, in a big part rewritten.

    I take your advice and will try the ws module for node.js

    Thanks, I'll be back to give some feedback and oh, if I manage to do a tic-tac-toe with the raw plug-in and node.js, it would be worth doing a clean tutorial on how to do it (I'm not there but it's a good goal at this stage !).

  • Well, this time the debug info stay on "Connecting to server...", there is no error either no connection done.

    The socket.io server log doesn't say anything at all (no incoming request).

    The cool thing is that I learn a little how all this works.

    I'll try to understand much what I'm doing, it's a bit more complicated than I was thinking at first =)

    PS : I forgot to use the marvellous C2 debugger... doesn't help right here but I should use it more often.