Jump to content
SubSpace Forum Network

Recommended Posts

Posted
Is it possible to mark (at least) four more tiles as special, and everything that hits them bounces off on the diagonal? That would make for much different basing gameplay (much better, imho).
Posted

I'm just curious, how would you go about doing it? Pretend that we've already designated the necessary tiles to function like we want them to, but how do they actually function?

 

I was thinking that congruency would work simplest. The angle that the bomb is reflected is going to be 180 - 2x, where x = the angle between the ray that the bomb comes in on and the wall itself.

hi.jpg

Posted
I'm just curious, how would you go about doing it? Pretend that we've already designated the necessary tiles to function like we want them to, but how do they actually function?

 

I was thinking that congruency would work simplest. The angle that the bomb is reflected is going to be 180 - 2x, where x = the angle between the ray that the bomb comes in on and the wall itself.

 

Yeah, the physics module works by updating a particle's position and velocity after a number of milliseconds elapse. First, after we check what tile the particle is entering and find that it's a slanted tile, we check if it's coming from the left or bottom (using the tile in your figure). Then if it's not we have to check where the collision with the diagonal line occurs exactly. We put both the formula for the diagonal line in the tile into the cooresponding line equations (y=mx+b, remember from pre-algebra?). Note that we can only do this if the slope exists (m = dy/dx, so if dx = 0 m doesn't exist, this cooresponds to a particle moving straight up or down).

 

If the slope doesn't exist, we can just plug the x value from the particle line into the equation for the diagonal line to get the y coordinate of the intersection. so, for example let's assume our tile is located at the origin in quadrent I. the equation for the diagonal line, in pixels, is y=(-1)x+16. Let's say a particle is moving straight down at x = 3. Putting 3 in for x we get y=(-1)(3)+16 which simplifies to 13. So now we know the collosion occurs at (3,13), which is actually a point on the diagonal.

 

If the slope does exist, meaning the particle isn't traveling straight up/down, we have to find the collision of the two lines. so in our example the tile line is y=(-1)x+16. Let's say a particle is moving normal to the diagonal tile surface. So let's say the equation for the particle is y=(1)x-2. We can find where the intersection is by setting the two equations equal to one another and solving for x, then pluging x into either equation and getting y out. so (-1)x+16=(1)x-2, use algebra to get -2x=-18, x=9. Now we can plug x=9 to either equation to get the y coordinate. 9-2=y, y=7, so the collision is at (9,7). Now we do a check to make sure this point is actually in the tile (the two lines may intersect outside of the tile, in which case we can safely ignore the particle as it passes through the passable part of this tile). Indeed 9,7 is within our 16x16 tile size, so we now just have to move the particle to it.

 

We get the distance from the original particle position and 9,7 using the pythagorean theorm. We can then use the velocity and distance to solve for time elapsed (v=d/t, t=d/v). If this time is less than the number of milliseconds we're advancing the particle, just advance it without bouncing, if not, subtract this time from the time to advance the particle, change the positon to 9,7, change the velocity as you described(incoming angle should equal outgoing angle, you can compute angle of particle from velocity and arctan), and go back to the begining of the physics loop to see if it his another tile during this update.

Posted

why not do pixel-perfect collision ? directx supports that (or so i've heard)

 

Edit: nvm, forgot that you have to calculate the direction where the bomb flies to rather than just check for collision:yes/no :oops:

 

hmm well if only triangle bounces are required, things can speed up a lot by doing 4 if .. then (see below) rather than calculate the exact solution:

 

1) -> \ : vx becomes vy (note that the offset when the bomb is not in center of the tile at left pos is linear to where it exits the tile)

2) \ <- : -vx becomes -vy

3) -> / : vx becomes -vy

4) / <- : vx becomes vy

 

there are 4 other for up and down but the relations between vx & vy stay the same

 

I dunno if this quicker solution for 45° only is useful but i think 100 bombs bumping into 100 of those tiles would make some hefty calculations

  • 2 months later...
Posted

In addition to diaganol special tiles...

 

Theres one tile that allows ships to fly thru it, but weapons blocked, woudl be cool to have the OPPOSITE of this, its somethign ive been wishing i could have for a logn time. Ships blocked, items go throught it. Would make for cool like walls that u can shoot over, barbed wire, low fences kinda thing.

Posted (edited)

It would be useful to be able to do any angle, and simpler. The fact is, all that's being done is a reflection of the motion respective to the wall. The problem with that, though, is that graphical tiles are being used rather than object shapes with textures, and also that the basis for wall detection in most 2D games like this seem to be based on rectangular areas (which can simplify things a bit, but is nevertheless less powerful). Can't say I've actually looked at what bak has done yet, but I just downloaded through svn.

 

p.s. is there any sorted to-do? and also, trying to compile DiscretionLinux gives me error 1.

 

../Modules/ModuleManager/../Module.h:13:29: error: Shared/Snprintf.h: No such file or directory

make: *** [DiscretionLinux/Modules/ModuleManager.so] Error 1

Edited by jake13jake
Posted

change Snprintf.h to snprintf.h

 

 

i'm pretty sure the linux build is out of date, broken, or both. The wiki page on the mgb forums has some suggested to do, although I'll start working on this soon so maybe a real list is in order.

Posted
change Snprintf.h to snprintf.h

 

 

i'm pretty sure the linux build is out of date, broken, or both. The wiki page on the mgb forums has some suggested to do, although I'll start working on this soon so maybe a real list is in order.

 

next one:

make: *** No rule to make target `../Modules/Graphics/SDL Graphics/SDL_image.h', needed by `DiscretionLinux/Modules/SDL Graphics.so'. Stop.

 

I really know nothing about how makefiles work, !@#$%^&*. What I really want to do is work on this project. But !@#$%^&*, I'm using Linux.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...