randomly's Forum Posts

  • Hey,

    what exactly do you want to do? Do you want to generate levels randomly?

    Or do you want to create the levels by yourself and include them in layouts?

    Give us some further information please.

  • First of all, how do you access the Internet in your game? Via AJAX?

    And did you add a "touch" object to your project?

    We will need some further info to help you.

  • Hey,

    we can't tell that from just your post.

    We need a capx or at least a screenshot of your current project/"on tap" event.

  • Hey y'all,

    I recently needed the angle of the mouse's movement in one of my projects.

    Essentially, I need the angle in which the user moves the mouse, e.g. for a duration of 0.2 seconds.

    My idea to solve this:

    I came up with the idea to create global variables which store the Mouse.X and Mouse.Y and get refreshed every 0.2 seconds (let's call them "LastKnownX" and "LastKnownY").

    As soon as either of those variables doesn't correspond with the current Mouse's position, the angle of movement is calculated via

    angle(LastKnownX,LastKnownY,Mouse.X,Mouse.Y)[/code:1u2ycl63]
    
    This works okay, isn't very smooth though.
    
    My question now is:
    [b]Is there a better (more effective) way of doing this?[/b]
    
    Thanks for any help.
    _____________________________
    .capx of my setup: https://www.dropbox.com/s/8gkhpl7smf2eh36/MouseAngle.capx?dl=1
    image of my current setup: http://i.imgur.com/3wtATXJ.png
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well, of course that is possible.

    If I understood you correctly, you have a single sprite which will go up and rotate clockwise when you hold the left key and go down and rotate counter-clockwise when you hold the right key?

    I'm a bit confused what your goal is because your thread's title sounds different to what you describe...

    I will just guess now that you want the sprite to move in the direction it is facing?

    So it does a curve when you hold either key?

    Well, if I understand you correctly, this is what you gotta do:

    • add the "Keyboard" object
    • add two "key pressed" conditions, one for the left and one for the right key.

    the actions in the "key pressed" condition for the left key would look like this:

    - Sprite: set angle to: "Self.Angle+?"
    [ul]
    	[li]Sprite: move forward: ?[/code:f76tkgc4][/li]
    [/ul]For the right key, it would be the same, just "Self.Angle[b]-[/b]?".
    
    Replace the ? with a degree of your favour for the Angle and a pixelamount of your favour, for the movement.
    The higher the value, the faster.
  • R0J0hound

    Thanks so much for answer!

    This works perfectly for predicting the impact while flying!

    The thing is, I want to predict the impact before launching. That means, since the initial speed and gravity are known, I could predict the impact x coordinate, right?

    I just need the right formula for that...

    As I said, your formula works perfectly for predicting the impact when the bullet is flying.

    I don't think though, that I can predict the impact point before the actual launch.

    The reason might be that the angle of motion can't be predicted in the formula for the process of flying.

    Maybe I'm really not grasping something here, or my idea isn't even possible.

    Thanks for your continuous dedication for my problem, I hope I'm clear enough about what my goal is here.

  • Hey baokinh ,

    I assembled a little capx over night in case you get stuck.

    It's nor perfect nor complete but I guess it showcases the two version pretty good.

    Have fun.

    Download:

    dropbox.com/s/58mxrdak8cxe9e3/TappingSpeed.capx

  • I'll see whether I can create a capx at some point including the two methods.

    Though there is this thing calles...private life, which keeps me from doing it.

    Goddamnit.

    Same here as for , I'll see when I have time, I'll go for it.

    But maybe those two solutions are enough initial thrust for you to launch your mind and get your project done.. ;)

  • baokinh

    Well, there are some possible ways you could go.

    The easiest one would be to have a global or instance variable, e.g. "speed", initial value = 0

    Your character would be moved horizontally based on the value of "speed".

    In detail, this means:

    • each time you tap, the value gets increased by a specific (and small) amount.
    • every x seconds or every tick (depending on your preference), the character gets moved +speed pixels on the horizontal axis

    (the faster you tap, the further the character goes)

    • every x seconds or every tick (again, depending on your preference), the "speed"-value gets decreased by a specific amount, causing the character to go backwards when the value is under zero.

    (To prevent the character going off-screen, you would have to clamp his x coordinate)

    The exact amounts and timings depend on your likings.

    This is the basic principle, I would go with. It seems the simplest to me.

    _________________

    If I wasn't clear enough, I can try to create an example project for you.

  • R0J0hound

    Thanks for the answer.

    Actually, the launching position is higher than the ground.

    I tried applying your original formula to my project, exchanging the speed to the bullet's speed and changing all other stuff to my equivalent objects (which didn't work).

    If I now want to use the solved two equations for an elevated launch position, what shall I modify?

    And for the initial y and x velocity, should I just take the velocities from the debug mode (being x=400 and y=0 on launch)? Because the Bullets behaviour obviously doesn't allow me to set x and y velocity seperately..

    [EDIT]

    I figured I maybe have to set the initial y velocity to launching_speed*sin(launching_angle)

    and the initial x velocity to launching_speed*cos(launching_angle).

    Since my launcher's angle is somehow always set as 360-actual_angle, I also figured I'd change the launching_angle to abs(360-launching_angle). Using this, my current setup looks like this: i.imgur.com/TK4pTAQ.png

    It kinda works, but the accuracy is always ± ca. 100 pixel (horizontally) which is not exactly what I'd consider accurate...any idea what I did wrong? Is it the elevated launching position?

  • Wanted to download the Free Assets .zip file on the bottom of every scirra.com page.

    It says "13MB", it's actually around 34MB.

    Nothing important, but worth mentioning I guess.

  • So what you basically want to do, is to load up those values for the last used slot?

    At the end of a game (e.g. when the player closes the game) you want those values to be saved and loaded up when the game starts the next time, right?

    Sorry, I still need to grasp what your plan is here. ;)

    If that is your idea, then what you need to do is:

    • add the Local Storage object to your project
    • at the point where you want to save the values to the Local Storage, add an action for Local Storage, by the name of Set item.

    Now you can choose a key name and the value for that key.

    You could either just go with one key and format your three values as a simple string which you would have to parse on the start of the game. [This could look like this:

    Set item "slot1" to: "#1" & HasSaveData_Slot1 & "#2" & CurrentLives_Slot1 & "#3" & CurrentWorld_Slot1[/code:3a4suqmx]At the start of the next game, you would then get the item "slot1" and parse the string via some system expressions ("find", "mid",...)]
    
    [b]Or you could simply[/b] go with three [i]set item[/i] actions to save each variable as an individual key.
    This would look like this:
    [code:3a4suqmx]Set item "HasSaveData_Slot1" to: HasSaveData_Slot1
    Set item "CurrentLives_Slot1" to: CurrentLives_Slot1
    Set item "CurrentWorld_Slot1" to: CurrentWorld_Slot1[/code:3a4suqmx]
    
    [b]No matter which option you choose:[/b]
    At the start of the game, you would go with an action[code:3a4suqmx]Check item "itemname" exists[/code:3a4suqmx]
    (replace "itemname" with either "slot1" or "HasSaveData_Slot1", .... depending on which option you chose previously)
    Followed by an event [code:3a4suqmx]On item "itemname" exists[/code:3a4suqmx]containing the action [code:3a4suqmx]Get item "itemname"[/code:3a4suqmx]
    You would then follow this again by an event[code:3a4suqmx]On item "itemname" get[/code:3a4suqmx] containing actions which either
    a) parse the single key "slot1" to apply them to the variables in the project
    or
    b) apply each of the three keys "HasSaveData_Slot1",... to the corresponding variables.
    
    That would be it.
    This sounds more complicated than it is and I would really like to assist you with images, but I can't do this atm.
    Of course, these instructions only apply if I understood your explanations correctly.
    
    I hope, I didn't explain the whole process to you when you already knew it and were asking for sth. completely different.
    Let's just hope I could help you somehow. :)
  • blackhornet

    That's a nice implementation, well done. Way smoother than mine.

    mrinmoysd

    I guess you have enough examples to start off on your own now, huh? :)

  • blackhornet

    That link doesn't work for me..

    Though your page is quite interesting..

  • Hey man,

    where exactly do you want to save those flags to at the start of the game?

    To global or local variables?

    And how are those flags stored in general? Are they stored via the LocalStorage object? Or in a variable?