2016-10-24 18:43:11

In the past, to create surfaces on a grid map, I would:
give the surface a start x, max x, start y, max y.
Then I would check if the player's x was between the start x and max x, and if their y was between start y and max y, and if it was then it meant they were on the surface.
  However, in my game there may be necessity for surfaces that don't face exactly 0, 90, 180, or 270 degrees. What I'm asking is, how do I make a surface that is facing, say, 45 or 59 or 69 degrees or whatever, and still be able to check if the player's coordinates are still within its bounds?
  If that's unclear, basically instead of creating a rectangle that is perfectly parallel with one axis and perpendicular to the other, I want one that could be slanted. I've looked this up on Google, but haven't quite found what I'm looking for.

If you have issues with Scramble, please contact support at the link below. I check here at least once a day, so this is the best avenue for submitting your issues and bug reports.
https://stevend.net/scramble/support

2016-10-24 19:22:54 (edited by CAE_Jones 2016-10-24 19:24:42)

You can make polygons by using a raise of points, so long as they are in either counterclockwise or clockwise order. There's some math in order to do hit detection with them, but I don't really know what off the top of my head. You could Google it, or I could try and find my to  2-D geometry library for BGT. (I can't really upload it right now) basically, there is an equation that will tell you which side of a line segment a point is, and whether not to line segments intersect. To tell if something why is inside a polygon, you need to be on the same side of each line segment, which is why they need to be    In order.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2016-10-25 17:28:57

Wouldn't that have a heavy CPU usage though since you're having to loop through a bunch of points for each of the surfaces? Some of these may be up to hundreds of coordinates long.

If you have issues with Scramble, please contact support at the link below. I check here at least once a day, so this is the best avenue for submitting your issues and bug reports.
https://stevend.net/scramble/support

2016-10-26 05:16:59

I've tested a tileset engine implementation with free-roaming sprites not strictly bound to tiles using circular collision detection, with each tile representing a 16 by 16 area. When a sprite walks into a tile it would register itself in a list at that particular grid point, other sprites in that sector would do the same. Each cycle, each individual sprite would then do a collision check only for those sprites in their immediate sectors to see if their two circle boundaries collided, so as to prevent having to comb through the entire sprite list for each and every sprite doing collision checks. So what you could do is have a collision grid represent an X by Y area, and then place your sprites over top, registering them in the various sectors they occupy. Each turn you'd check if their sector occupies the same space with another object and then do a collision check for them.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2016-10-26 14:35:32 (edited by CAE_Jones 2016-10-26 14:37:08)

Yes, you would need to do something like that. Also, this method only really works if it's a convex polygon, so all of the exterior angles must be less than 180°.  So, if you wanted to make something it doesn't fit that description, you would need to combine multiple shapes. For example, deal the star of triangles, or an arrow out of a triangle and a rectangle.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2016-10-27 13:18:47

Here's the most up-to-date version of my BGT geometry library. Note that I combined it with Sam_Tuby's rotation package, which resulted in variable name collisions with pi, so if you try to use 2d or 3d and you get a compilation error that it can't find pi, just add

const double pi=3.14159265[...]

Somewhere in your code.
Readme2d.txt explains how to use 2d.bgt.
3d, phys, and object have not been documented. Phys has more 3d hit detection functions, and object has more factory functions and a minimalist object class. If you only need 2d, you can ignore these.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2016-10-28 05:40:31

Compilation error.
In cae_jone's post, line 3.141592.
Missing link to /2d_lib.zip.

If you have issues with Scramble, please contact support at the link below. I check here at least once a day, so this is the best avenue for submitting your issues and bug reports.
https://stevend.net/scramble/support

2016-10-29 14:22:12

Eeeee! For real this time:
https://www.sendspace.com/file/q37jld
2d contains:
- shape interface
- geometry functions
- some basic shapes (rectangle, circle, polygon, right triangle)
3d contains:
- form interface
- basic forms (sphere, box, cylinder, cone, mesh)
phys contains:
- additional collision functions for forms
- super incomplete 3d movement functions
Phys includes 3d, and 3d includes 2d.
The collision functions in phys are pretty slow, especially when cylinders and cones are involved.
I could not figure out how to do 2d paths that aren't convex, since the examples I found used proprietary code to calculate path crossings for curves and lines. Otherwise there would probably be paths in there, too.
3d meshes use axis-aligned polygons to define their boundary. It's not relevant for what you're asking about, but I'm not sure if I can explain exactly how they work...

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2016-12-22 19:15:27

Hello. Sorry, but the link doesn't work. It says download error. The file is deleted and blah blahblah. Is it possible for you to re-upload it again?
thanks.

---
Co-founder of Sonorous Arts.
Check out Sonorous Arts on github: https://github.com/sonorous-arts/
my Discord: kianoosh.shakeri2#2988

2016-12-23 16:00:01

Here it is:
https://www.sendspace.com/file/f3bmv0
I updated some things since the last post, but I don't remember what. They're only in the 3d, obj, and phys modules, though.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.