new to C2, got a minor question and a critical one

0 favourites
  • 13 posts
From the Asset Store
Create your game with this complete pack of images and animations!
  • First the easy part:

    1) How do I make an object bounce from the player sprite a short distance? I have programmed a bullrush move, and I want enemies to bounce off of him. This works fine if I add the bullet behavior to the enemy, and the enemy speed is >0, but if I want still objects (speed=0) to bounce, the bullet behavior doesn't work at all. Move at an angle is way too abrupt and is more like a teleport.

    Here is the kicker:

    2) This answer will determine whether or not I purchase this program. How efficient is the coding? I am using the free version, obviously, and I have started scripting out a very complicated game. I am close to the 100 event limit, and the player has over 50 instance variables and 50 frames of placeholder animations (colored squares essentially), and there are 30-ish objects on screen. No physics have been enabled. When I run it on IE and my friend runs it on Firefox, if I double the movement speed of the character and zoom around for about 15 seconds, the layout throws up out of memory errors and crashes. If IE crashes, I'm not really that surprised, but I really can't tolerate a game that can't run on Firefox. How many "lines of code" can C2 support before it becomes a lagfest?

    Thanks!

  • When you say you want objects to "bounce" even if their speed = 0, this surely implies there is a collision and if there's a collision it's extremely easy to use the collision trigger to achieve what you want.

    You're basically going to need to use the On collision to trigger "set bullet speed"&"set bullet angle of motion" actions on the inert object.

    Secondly in my experience C2 can handle far more code than you could possibly throw at it with the free version, crashing after 5 secs implies to me you've either got a recursive loop kicking in or your code is continually spawning objects. Does it go out of memory if you do nothing or is it only if you move? Have you tried debugging it to see where the resources are being used?

  • For the second one.. Please upload your example .capx to somewhere to be seen (like dropbox). It's nearly impossible to comment without seeing the original problem. Especially if there's some mistake (or logic fault) at the event code, it's mandatory to see the files and be able to run them on one's own PC.

  • When you say you want objects to "bounce" even if their speed = 0, this surely implies there is a collision and if there's a collision it's extremely easy to use the collision trigger to achieve what you want.

    You're basically going to need to use the On collision to trigger "set bullet speed"&"set bullet angle of motion" actions on the inert object.

    Secondly in my experience C2 can handle far more code than you could possibly throw at it with the free version, crashing after 5 secs implies to me you've either got a recursive loop kicking in or your code is continually spawning objects. Does it go out of memory if you do nothing or is it only if you move? Have you tried debugging it to see where the resources are being used?

    1) I set the player to solid temporarily, set its speed. Then I made the motionless object a bullet, set it to bounce off solids, and set its speed to zero. I run into the object and pass right through it. If I set the bullet angle and speed, won't it fly off into oblivion? I was hoping for it to bounce a distance, slow down, and then stop.

    2) Thank you, that is what I was hoping for. I am planning for several thousand "lines of code." I was worried that a web game would not be able to support it.

    For the second one.. Please upload your example .capx to somewhere to be seen (like dropbox). It's nearly impossible to comment without seeing the original problem. Especially if there's some mistake (or logic fault) at the event code, it's mandatory to see the files and be able to run them on one's own PC.

    Thank you for offering to look at it! I don' have permission to share links, so please insert and replace what's necessary .

    //dropbox link/s/a026ni9nf1nu06q/construct_test.

  • Perhaps you should try a few of the beginner tutorials before getting too deep into things.

    There are a few telltale things you haven't thought about such as "50 frames of animation", and "several thousand lines of code".

    That's not going to work on any platform.

    You can't just pile things on and hope for the best.

  • Whoops, I accidentally deleted the file. Here is a new link. Again, please insert the dropbox com address:

    /s/cxnd6qk9g054081/construct_test.capx

  • Perhaps you should try a few of the beginner tutorials before getting too deep into things.

    There are a few telltale things you haven't thought about such as "50 frames of animation", and "several thousand lines of code".

    That's not going to work on any platform.

    You can't just pile things on and hope for the best.

    I'm not sure what you mean. Are you suggesting Super Ubie Land doesn't have more than 50 frames of animation in the entire game? Or at least several hundred lines of code? I'm also not sure how a beginner's tutorial would show me how to program efficiently.

  • I see a whole lot of inefficient programming, repeating the same conditions.

    For instance:

    The last three events all start with for each damagesource. Wouldn't it be easier to combine these?

  • The question isn't if that can be done, obviously it can.

    Just saying you may not be up to that level yet.

    Find the bugs, fix them.

    Id suggest starting with the "for each" running every tick.

  • Thanks for the help! Aside from inefficiencies, which will need to be cleaned up later, I'm looking for memory leaks and sources of crashes.

    For instance, I have the opacity set to 100 whenever isCloaked is false, and set it to 50 when isCloaked is true. I know that is a bunch of actions that don't need to happen if I just set the opacity to every time it is toggled rather than running all the time. Will things like that crash my program?

  • Your big problem is the array "aggroArray" or rather the two instances of aggroArray that are created.

    They are both increasing in size very rapidly indeed and are running the Browser out of mem.

    Here's a pic of one, don't forget there are two instances increasing at the same rate which I guess is per tick or 60 times per second.

    <img src="http://s22.postimg.org/htzglpc69/array.jpg" border="0" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry I'm timing out a lot.

    The above post should have also read

    Fire up the debugger and watch what happens and where the resources go.

    scirra.com/blog/124/introducing-the-construct-2-debugger-and-profiler

  • Thanks so much guys. I was actually just wondering if C2 could handle thousands of events, and that question was answered. I know there are inefficiencies in programming that need to be fixed eventually, and I appreciate you guys helping me with it. My program was actually crashing before I added that aggro array stuff (everything south of "Debugging" is just testbed stuff that I throw in as I'm thinking about it so I don't forget, and I just added it).

    But while we're on the subject, I wanted to create a 2D array with names in one column (x0) and number values in the second column (x1), and I wanted it to be as dynamic as possible, meaning for each new object on the screen, I can push a name onto x0y1 and a corresponding number onto x1y1. Is there a way to do that? I can't get my head around the push action in the manual.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)