soggyclog's Recent Forum Activity

  • Thanks guys!

    Here's the capx and shader. Remember to copy the .FX and .XML into your C2/Effects folder.

    Download me

    RandomFellow Thanks man, yeah you're right, but I don't mind it looking like lava, it was just a test anyway. I'm also not used to working in GLSL, so my attempts to clamp values like I would in HLSL weren't working and I couldn't be bothered so I just went with it and let it go into bright hot lava colours :)

  • This looks really nice!

  • Ended up looking more like lava really.

    Link

    Just a quick test, not sure if I did it efficiently or how you're supposed to.

    It just uses an array to store 1s wherever there's existing lava or a wall, and 0s where there is empty space. Each frame it loops through all the lava cells and checks the array to see if there's empty space in any adjacent cell below it, if there is then it moves the lava sprite there and updates the array accordingly.

    The blobby look was accomplished by applying blur shaders to the layer, then sharpening the alpha back to a hard edge using a threshold shader.

  • Thanks a lot guys, this is awesome!

  • So I got pretty excited when I first saw Maciej's post about Appmobi over in the fundry thread. And even more so when touch support went into the latest build of C2. Basically we can now make native apps for mobile phones using Construct 2 which is pretty damn amazing if you ask me

    Unfortunately even the most basic test application with a single moving sprite seems to run a bit slow on my friend's Android, but hopefully performance will improve in time.

    Anyway, one thing I wanted to share is a way to scale a C2 game based on a phone's screen resolution. As you know, Android phones come in many shapes and sizes with different screen resolutions. Then there are iPhones and iPads to further complicate things. You can use some DIV formatting in the index.html file to stretch the canvas to fullscreen but in my experience it throws things off and is ugly. Instead what we need is something like Construct 0.x's DisplayWidth and DisplayHeight to use in expressions within Construct 2 so that we can position and scale sprites correctly based on the available space. I'm sure this will eventually be possible but heres a hacky workaround till then (note: im not a programmer so try not to cringe if this is a horrible way of doing it)

    In Construct 2:

    Create two text objects. These will be used to store the screen's dimensions. Once we have global variables you should use those instead.

    Then on the start of the layout, set a temporary number as the text for each.

    On Start of Layout:
    	TextX: Set text to str(320)
    	TextY: Set text to str(500)[/code:3k9axzz6]
    
    Now simply pretend TextX represents the screen width and TextY the height and use their text values the same way you would the DisplayWidth and DisplayWidth expressions. Keep in mind that you have to convert these values to integers first, like so: int(TextX.Text)
    
    Once you're ready to try it on a phone, export it to HTML5. Find c2runtime.js among the exported files and open it for edit in Notepad++ or equivalent.
    
    Do a search for TextX and keep going till you find the "SetText" entry under actions. It should look something like this:
    [code:3k9axzz6]"actions": [
    			{
    				"type": "TextX",
    				"method": "SetText"
    ,				"parameters": [
    				{
    					"type": "any",
    					"expression": {
    						"type": "system_exp",
    						"name": "str"
    ,						"parameters": [
    {
    							"type": "int",
    							"value": 320
    						}
    [/code:3k9axzz6]
    Where it says [b]"value": 320[/b], simply replace the hardcoded number [b]320[/b] with [b]window.outerWidth[/b].
    
    So it should now read: [code:3k9axzz6]"value": window.outerWidth[/code:3k9axzz6]
    Do the same thing for TextY but replace that with [code:3k9axzz6]"value": window.outerHeight[/code:3k9axzz6]
    Save and close this file.
    
    Now edit the index.html and replace its contents with this: 
    [code:3k9axzz6]<head>
    <style type='text/css'>
    div {position:absolute;left:0px;top:0px;width:100%;height:100%;}
    </style>
    <title>New project</title>
    
    	<style type="text/css">
    		canvas { border: 1px solid black; }
    	</style>
    	<script type="text/javascript" src="jquery-1.4.4.min.js"></script>
    	<script type="text/javascript" src="c2runtime.js"></script>	
    
    <script type="text/javascript">
            // Start the Construct 2 project running on window load.
            jQuery(document).ready(function ()
            {
                // Create new runtime based on the preview canvas element
                var project = new cr.runtime(document.getElementById("c2canvas"));
    
                // Load and start running
                project.load();
                project.go();
            });
        </script>
    </head>
    <body>
    <div><canvas id="c2canvas" oncontextmenu="return false;">
    <!-- This text is displayed if the visitor's browser does not support HTML5.
                You can change it, but it is a good idea to link to a description of a browser
                and provide some links to download some popular HTML5-compatible browsers. -->
    			Your browser does not appear to support HTML5.  Try upgrading your browser to the latest version.  <a href="http://www.whatbrowser.org">What is a browser?</a>
    			<br/><br/><a href="http://www.microsoft.com/windows/internet-explorer/default.aspx">Microsoft Internet Explorer</a><br/>
    			<a href="http://www.mozilla.com/firefox/">Mozilla Firefox</a><br/>
    			<a href="http://www.google.com/chrome/">Google Chrome</a><br/>
    			<a href="http://www.apple.com/safari/download/">Apple Safari</a>
    </canvas></div>
    <script type="text/Javascript">
    //get div to gain access to window size
    div=document.getElementsByTagName('div')[0]
    //set canvas size to the whole window 
    canvas=document.getElementsByTagName('canvas')[0]
    canvas.width=div.scrollWidth
    canvas.height=div.scrollHeight
    </script>
    </body>[/code:3k9axzz6]
    It probably doesn't need any of the browser checking but whatever. It's just a slightly modified default index.html that makes the canvas fullscreen without actually stretching the contents.
    
    That's it. Now you can convert it to a mobile app using AppMobi and it should get each phones screen dimensions fed into the two text objects.
    
    Here's a simple example project that positions four decorative sprites exactly in the screen's corners 
    <img src="http://www.rustwork.com/temp/app_SS.JPG">
    
    Here's a zip file containing the xcap and the modified exported files:
    [url=http://www.rustwork.com/temp/screensize.zip]screensize.zip[/url]
    
    NOTE: This will only look correct on phones. In browsers and AppMobi's emulator it's way off. 
    
    PS.: Sorry about the wall of text  
    
    EDIT: I've only tested this on Android so no guarantees that it'll work on iPhones or other things. I'm hoping it does.
  • Wow! You guys are making amazing progress on C2! Haven't had time to play around too much but tomorrow I'll MAKE time

    I'm very curious about trying the touch plugin with that AppMobi thing. Exciting.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I've noticed that the RTS pathfinding doesnt work when the layout is set to Unbounded scrolling, which makes sense since it can't build an infinite map to work with.

    Just wondering if there is any trick to get it to regularly regenerate a finite pathfinding map only around the currently viewed portion of the infinite layout. I can't see that this would be supported but thought I'd ask anyway...

  • This is great! I love useful tools like this.

    Thanks for sharing!:)

  • If I use python script to do basic things then the EXE runs fine as long as the python26.dll is in the folder.

    But I just tried using the random module and the exported EXE no longer works eventhough it runs fine within Construct.

    My test script is very simple:

    import random
    
    SEED = 123
    random.seed(SEED)
    System.SetGlobalVar('x', random.randrange(0, 100))[/code:djpa2kif]
    When I run the EXE it complains something about random.pyc and about not finding __future__
    
    So in the export wizard I tried checking the __future__ and random.pyc modules, which fixed the __future__ error but not the "random" one.
    
    The error message it gives me is:
    
    [i]Traceback (most recent call last):
    File "<string>", line 1, in <module> 
    File "random.pyc", line 43, in <module>
    ImportError: No module named warnings[/i]
    
    Can someone please point out what I'm doing wrong?
  • If you simply want to change the appearance of the copied sprite you can also use the same sprite and just set them to use different frames.

    Demonstrated nicely here:

    If you need to distinguish between them in the event sheet you can pick them by animation frame.

  • Dude... seriously. Very cool!

  • Wow that's really quite amazing Quazi

    Now if only you named your objects and vars something descriptive instead of random letters

    Though I probably still wouldn't understand it...

soggyclog's avatar

soggyclog

Member since 24 May, 2009

None one is following soggyclog yet!

Trophy Case

  • 15-Year Club

Progress

15/44
How to earn trophies