Proxymity's Forum Posts

  • Cheers SputnikCZ,

    as far as I understood, you want to give the player money and lumber as soon as they unlock the building - not before? The simplest way, which comes in my mind, declare a local bool (or a variable is also possible):

    if amout of buildings < 0 then

    activate group "produce"

    else

    deactivate group "produce"

    ... or in a picture:

    (this should have minimal impact on cpu, because you are not checking something on "every second")

    Hopefully, thats what you needed to know (getting tired...).

    Best regards

    Proxy

  • Hi guys!

    I'm writing my first C2 plugin (better to say, my first (bigger) confrontation with JS).

    I know what CORS is - and already had the one or another meet with it.

    Background info:

    I'm writing a little framework which handles account managing and data storation for a C2 dev. Ive seen a lot questions about accounting, etc. - got a great help days back - and now I'ld like to share my knowledge with anyone who doesnt know how to ajax userdata via php into a mysql db. For that Im rewriting an account managing system (with all its needs, registering, login, "forgot password"-function, token based, "remember me" function, etc..; incl. storing data (preffered as JSON) in the backend). But more to the plugin when its ready to see the light of beta-testers...

    To my problem:

    When I got a simple return...

    <?php
    header("Access-Control-Allow-Origin:*"); // Allow all origins
    
    $InputAction = $_POST["Action"]; // Eventhandler
    
    if ($InputAction == "Register") {
    		echo("-400")
    }
    ?>[/code:25w51riy]
    ... everything works fine. Even if Im extending the whole stuff. CORS is on * in row 2 as you can see (I was told from different sources, that its best to build a func, etc etc... but sources like [url]http://enable-cors.org/server_php.html[/url] also told me, that the one-row is ok. And unless Ive tested it with several scripts (including AJAX cross domain requests out of C2), Im at least sure that it works.
    
    Now, when I extend the source of the serversided script, like...
    
    [code:25w51riy]<?php
    header("Access-Control-Allow-Origin:*"); // Allow all origins
    
    require('includes/config.php'); // Prerequisite
    
    /** Numeric callbacks (!negative values!)
    -200 Registration successful; validation mail sended
    -250 Username OK
    
    -300 Username too short
    -301 Username already in use
    -302 Password too short
    -303 Invalid email address
    -304 Email already in use
    -305 Error while registration
    
    -400 Illegal request
    **/
    
    $InputAction = $_POST["Action"]; // Eventhandler
    
    $InputUsername = $_POST["Username"]; // Requesting username
    $InputMailaddress = $_POST["Mailaddress"]; // Requesting mail address
    $InputPassword = $_POST["Password"]; // Requesting password
    
    if ($InputAction == "Register") { // Action: Register
    	if(strlen($InputUsername) < 3){ // Check Username length
    		$error[] = 'Username is too short.';
    		echo("-300");
    	} else { // Check if username already exists
    		$stmt = $db->prepare('SELECT username FROM members WHERE username = :username');
    		$stmt->execute(array(':username' => $InputUsername));
    		$row = $stmt->fetch(PDO::FETCH_ASSOC);
    		echo("-250");
    
    		if(!empty($row['username'])){ // If username already taken
    			$error[] = 'Username provided is already in use.';
    			echo("-301");
    		}
    	}
    }
    else {
    	echo("-400");
    }
    ?>[/code:25w51riy]
    
    ... (its only a snipped, which could be used as a standalone "give me feedback!"-debug tool) Im getting a 500:
    
    [code:25w51riy]XMLHttpRequest cannot load http://api.proxy.wtf/debug.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.0.14:50001' is therefore not allowed access. The response had HTTP status code 500.[/code:25w51riy]
    
    There is no mistake in the syntax (the http-ui works perfectly; which contains same parts of the script in a single *.PHP) and I cant figure out whats going wrong here. I
    
    Does someone may have an idea whats going wrong here? After about 11 hours of work on the C2 plugin, everything breaks together because of this, driving me nuts....
    
    Have a great day,
    Proxy
  • Hi guys,

    the solution I got is a bit (too) rudimentary (plus very random in duration and questionable in effectiveness, no doubt):

    Does someone know a more accurate way? Im generating a map (dungeon) randomly and the player should be placed somewhere on a walkable spot (the worldgeneration starts in the middle of the generated field). I would like to use that routine also for spawning enemies, interactive objects, stairs, etc.. With my "solution" it *might* be possible to place the player (somewhat between instant and X minutes, depending on whats generated).

    Does someone can offer a player- and time-friendlier solution?

    Have a great day,

    Proxy

    Edit: also thought about extracting the JSON of the tilemap and search in that for the ID I want, but this likely will take the first match every time - so the player will always start in the top left corner, what I dont really want - and placing the enemies with that way would end in a massacre (without an exit )

  • Just curious if you worked on this/there are updates?

  • Proxymity Thank you for your answer! I'll do it that way now, works fine. But out of curiosity: Would it be possible to write that into a .txt file?

    Glad I could help <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";-)" title="Wink">

    Hmm.. lets say: there has to be a way to download a *.txt file. Personally I didnt needed that before, so I cant tell you exactly how to <img src="{SMILIES_PATH}/icon_question.gif" alt=":?:" title="Question">

    But what I sure can say is, that you could modify the "WriteLog" function to additi-break- while writing this I took a look at the browser manual, maybe the "Invoke download of string" or "Invoke download" will fit your needs (https://www.scirra.com/manual/110/browser).

  • Hi MPPlantOfficial,

    can you provide us your *.capx?

  • Hi elbando,

    if you dont need to download it (if its ok for you to get the log-output into a textbox (multiline) where you can copy&pasta it somewhere else):

    1 multiline TextBox is needed for that. Call your "Debug"- function and give it a parameter (Param(0) in my exmaple); for example:

    "RandomValue: " & aRandomValue[/code:1ww4xs0t]
    
    Thats the way Im logging stuff in my projects.
    
    Have a great weekend,
    Proxy
  • Hi Sherlautten,

    before I paused it, I worked on a project (and are still working ) which also gots a "list & search open games" with X slots for each player. That part isnt really finished (and still needs more work).

    Are you using the same backend-logic for creating and showing/listing rooms as in the tutorial you mentioned? How are you sending the informations to all clients, when a room opens? You possibly could include a 2D array which includes all relevant informations about each rooms and is sended AsJSON to all clients everytime the client/list refreshs; after recieving the array, put it into an another array and show its contents on the list. This could also be possible with variables & parameters. Try posting the link with spaces in it after and before each "." so we still can take a look in.

    Have a great weekend,

    Proxy

  • Wishy that sounds like it would work but how would I test if its a new install or not?

    Hi HZGaming,

    the best way in my opinion (requires some knowledge in with AJAX plugin, also MySQL and a little PHP is needed) is, building up your own little framework/api where a user has the option to register (not speaking of Facebook - or something you dont want to have ; Username & PW is totally enough.. maybe an optional mail-address for beeing able to recover his password). This enables such great ways and features to extend an app (having the same savegame on different devices, etc.).

    I think in any way you should head for some webstored data (speaking of MySQL, PHP-to-TXT-Scripts, etc.). When I read "Restore purchases" I understand "restore them under any circumsances", meaning: even when flashing a new ROM to your device or changing it (after a guarantee repair, for example), I am able to restore them.

    An another way could be including Google Play services into your project (there are plenty tutorials in the forums/tutorial-section for it) - but even then, if you want to cover all scenarios of loosing data, you have to store things externally of a device (where MySQL comes back again ;D).

    Good luck with your project and have a great weekend,

    Proxy

  • Click in your root folder at the very top of your list, then head to that attributes in the legt panel - there you can set the default layout.

    Regards,

    Proxy

  • Thank you for taking me serious independed of my childish English. I cant do better.

    First off, its not important if your english (or whatever language you write) is correct or not (my english isnt better at all.. <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":-D" title="Very Happy">), the context of what you are writing about is - and yours is! <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";-)" title="Wink">

    Indeed, your points are right. I just tested it out a bit, playing arround (the player now auto-attacks in 3 second intervalls, the enemy attacks with the same function in 0.5s intervalls). The "animations" are looking fine, also the GUI (after pressing attack, the attack-buttons are faded out (and will be faded in back again when cooldown=0)).

    Arent wait timers frame indipendend? Normally they should not be affected by framerates in generell. For every kinds of movements Im going to use dt. There shouldnt be *that* many particles (if realizable, Im going to make a little benchmark on the first start, getting the cpu usage/framerate while showing a few particles; then the game should set up correctly itself for having the best gfx/framerate option... gonna make a "graphic" option menu where the player can adjust things like max. particles shown or particle-quality in general for choosing his best experience ingame) because its aimed for mobile devices. Testing this will become a bit hard, because I got a nvidia shield k1 which doesnt represent the hardware on Android in general (and a Lumia 640, which is also not that interesting for the most users).

    Back to topic:

    Yes, you are right about what you say on timers/wait-actions. But while testing I didnt encountered any problem with that. At first Im doing the PvE version - PvP is part of a far future for this project (when its about doing the PvP part Ill do a server/client version... PvP games are hotspots for hackers, so the client will only be there for sending requests to the server/backend which does everything when it comes to calculate, displaying health, etc.; the client will only be there for the "visuals" - but thats another point which isnt worth mentioning here.

    Heres a "demo" of the current state (sorry for the very rudimental graphics.. how I said, first I need the core-system, then Ill go for gui, graphics and the stuff that makes fun.. gfx used are from Kenney, if one wants to know: http://kenney.nl/projects/kenney-game-assets-2), enemy attacks in 1.5s intervalls. To attack, just press the light-green-button (bottom left of the gui above the right player character):

    (to /2: while testing I didnt encountered problems, as already said)

    http://proxy.wtf/construct2/combat_system_test_timers/

    to 4/

    As the "wait" time is influenced by the attack-speed which is calculated out of your stats, I (at least hopefully) think, that the "unpersonal" scenario will not hit onto this. Ill also have no collisions (sprite collisions); I plan to include hitboxes. Since there wont be a "dodge" action, I dont have worries about that point. When player/enemy is killed, im going to deactivate the groups which are responsable for initiating attacks.

    Ive also tested "signals" and waiting for them, but that would extent the code pretty much, thats why Ive chosen the wait action.

    Sorry for that wall of text <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";-)" title="Wink">

    Have a great day,

    Proxy

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I had the same problem several times - and I didnt found a solution yet.

    You might create a 1x1 px sprite, center it in your layout (just do layout.X/2 and layout.Y/2) and give it the ScrollTo behavoir. In order to shake, you have to "show the borders". You could also zoom as the ScrollTo sprite as the center (zoom in about 5% or something) and then shake; after the shake zoom back.

    Regards,

    Proxy

  • Hi justintime0185,

    when having 8-way movement, give the player also the platform-movement behaviour and set initial state to false. Make a new event, if space (or an another button) is pressed = simulate jump (platform behaviour). I think its the simplest way to achieve jumping with 8-way movement. (you'll have to add a keyboard to your project file, if you want to get it done by pressing a key, otherwise youll need a sprite for the GUI input and a mouse/touch object in your project; then: "if sprite is clicked/touched then simulate jump").

    Regards,

    Proxy

  • Here you go (with a understandable commented source): https://www.scirra.com/tutorials/902/li ... raycasting <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";-)" title="Wink">