Dangerous Dave style shooting?

Get help using Construct 2

Post » Thu Jan 12, 2017 10:32 pm

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
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Thu Jan 12, 2017 10:56 pm

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)
Image ImageImage
B
168
S
50
G
164
Posts: 8,236
Reputation: 105,591

Post » Fri Jan 13, 2017 12:52 am

newt wrote: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.
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Fri Jan 13, 2017 2:02 am

Are you trying to do some sort of laser sight?
Image ImageImage
B
168
S
50
G
164
Posts: 8,236
Reputation: 105,591

Post » Fri Jan 13, 2017 6:20 am

newt wrote: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?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Fri Jan 13, 2017 6:37 am

B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Fri Jan 13, 2017 10:48 am

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?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Fri Jan 13, 2017 7:58 pm

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
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Sun Jan 15, 2017 9:23 pm

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.
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Tue Jan 17, 2017 3:38 pm

What do you think, @newt ?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: DarknessGamingDK, webebiz and 1 guest