Dangerous Dave style shooting?

0 favourites
From the Asset Store
Shoot balls to destroy as many blocks as possible, at each stage the game will become more difficult.
  • Like I said you can mess with the los settings, or test the targets xy's, or use the third party ray trace plug.

    I've never figured out how to test the offset position of an adjacent Sprite, in this case, is it above or below or on the same trajectory. Is that how you would suggest testing?

  • The capx already shows you how to test above, or below.

    You just need an x component.

    Test if the los target x is within the player's x minus n, and the player's x + n.

  • The capx already shows you how to test above, or below.

    You just need an x component.

    Test if the los target x is within the player's x minus n, and the player's x + n.

    Here's something I tried with the raycaster, as you suggested: https://www.dropbox.com/s/07koqkknhtmnj ... .capx?dl=0

    I just can't get the angle correct, if I use the edge of the layout or the start of the layout, depending on the direction the player is facing, that's fine for a straight line, but I can't add the 45 degree angle consistently if you press up. The great thing is I can control the width of the firing line with the trace sprite, but I'm not sure how this will be for performance if it's invisible (I could extend the trace sprite width to cover double the players height to allow for an error of margin).

    Any ideas how to make the ray cast at a perfect 45 degree angle if you're pressing up at all positions in the level, mathematically speaking? Presumably by adjusting the X position?

  • I'm not sure what you are going for compared to the original video.

    If I were to use the trace plug, when I wanted to shoot, I would pick the closest badguy, trace to its xy from the player, check its distance, and then compare its x, and y to determine up/down etc.

    All the trace does is determine if it has a clear shot.

  • I'm not sure what you are going for compared to the original video.

    If I were to use the trace plug, when I wanted to shoot, I would pick the closest badguy, trace to its xy from the player, check its distance, and then compare its x, and y to determine up/down etc.

    All the trace does is determine if it has a clear shot.

    Yeah you're right, I'm doing just that, in a way. So, I need to compare trace to the badguy, I couldn't think of a way of doing that, cause the x,y would have to be exactly the same as the badguy, wouldn't it? What would I use to compare trace to the badguy? I think trace looks perfect for this, really, I just don't know how to tweak the angle properly.

  • Here's one working with distance, I had to use a for each loop, is that okay? https://www.dropbox.com/s/x1fz2zfmm86q0 ... .capx?dl=0

  • I don't know what you need an angle for.

    All the shoot event would care about is if there was a target within range, if that target was above or below the player, and if it has a clear shot to it.

    Im not even sure it needs to have a clear shot in the video.

    Now if you want to have more frames for more angles, you would check if the y was in multiple places like player y though player y + 32 would be one level above the player, and player y+32 though player y+ 64 would be 2 above the player, and you would change frames according to that.

    Note: I say frames, unless you want to do a multi-image sprite like in Spriter, then you would use the angle(player.x,player.y,badguy.x,badguy.y)

  • I don't know what you need an angle for.

    All the shoot event would care about is if there was a target within range, if that target was above or below the player, and if it has a clear shot to it.

    Im not even sure it needs to have a clear shot in the video.

    Now if you want to have more frames for more angles, you would check if the y was in multiple places like player y though player y + 32 would be one level above the player, and player y+32 though player y+ 64 would be 2 above the player, and you would change frames according to that.

    Note: I say frames, unless you want to do a multi-image sprite like in Spriter, then you would use the angle(player.x,player.y,badguy.x,badguy.y)

    Yeah, I just need the angle to work out what's in the way of fire: https://www.dropbox.com/s/nydz7dk0le6l9 ... .capx?dl=0

    This unfortunately isn't a fixed angle, it changes depending on how close to the edge of the viewport you are. Any ideas how to fix this at a 45 degree? Then the trace will be perfect, I'm not sure if the foreach loop is efficient enough, shame system expressions like distance can't work per instance.

  • Are you trying to do some sort of laser sight?

  • Are you trying to do some sort of laser sight?

    I guess so, it's so it's like using an invisible bullet, but instantaneous, plus I can have bullets ricochet off surfaces, but since the end of the trace is absolute, i can't get a 45 degree angle to stay consistent. Is there some sort of trigonometry that sets the distance according to angle or something?

  • Maybe i was overthinking it: https://www.dropbox.com/s/2slsyuyacgr1a ... .capx?dl=0

  • Using viewport right and left works for the normal aiming, but it fails miserably when I add some altitude to the Y for aiming up cos when you get close to the layout edge, your aim goes sharper inclined. So what I really need to do is set the second trace end relative to an angle and have the end point stop at the edge of the viewport, that way the angle would be consistent depending on how close or far from the level edge you are, but you never end up aiming outside of the vid able region. So what maths would I need for this?

  • Basically, I need to be able to know what maths to use:

    • to adjust the Y of the end point
    • when the X is positioned on the viewportright/left
    • and the start point is the player
    • to keep the ray at a 45 degree angle regardless of the players distance from the viewportright/left
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • EDIT: Fixed links!

    Okay, here's what I have so far, and it's terrible: https://www.dropbox.com/s/g61zuyo6gggk3 ... .capx?dl=0

    Here's the raycaster plugin: https://dl.dropboxusercontent.com/u/207 ... ce.c2addon

    This is the original game and it runs in the browser, so if you'd like to compare where his fires, here it is: https://archive.org/details/msdos_Dange ... nsion_1991

    I just can't quite work out how far to send the beam, since it shouldn't really go any further than the viewport, and the angle height is difficult to get right depending on how close to the edges you are, in my example, it doesn't work for the top of the level, the angle turns into a hard horizontal line.

  • What do you think, newt ?

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