The rectangle tag has no usage guidance.
1
vote
1answer
49 views
LibGDX - Rectangle Collision and Response
I've been using LibGDX for the past few weeks and I have some problems that I need help on. What I need help on is understanding how to use LibGDX Rectangle class for a platformer.
I found this ...
1
vote
2answers
81 views
Using sprites in pygame without classes and objects
Relevant information
I'm in a grade 11 computer science class that uses Python & Pygame. We're aloud to use sprites and images though we're never taught it, just drawing graphics like squares and ...
0
votes
1answer
38 views
pygame scrolling: target moves faster than the camera
I know many questions have already been asked on this same topic, but I can't figure out from those how to solve my problem (possibly due to a different approach to achieve the same goal: scrolling my ...
0
votes
1answer
53 views
Android: How to prevent player(drag/drop touch input) from moving through non-moving objects?
My player is moved around the screen by touch user input. The user touches the character and drags him to another position. (implemented in touchevent: actionmove and actiondown). I want the touch-...
0
votes
2answers
61 views
Correct velocity on collision between two rects
I have two moving objects. The objects consist of a velocity vector2, a rectangle and a vector2 as position (origin in the middle of the rect).
Some rough pseudo code for my collision checking ...
2
votes
0answers
36 views
FillRecatangle set Opacity?
I have a game with "hud" which is drawn by fillrectangle.
How would I fade these fillrectangles when the player is on the "hud"?
1
vote
0answers
117 views
WebGL Primitive Batching unexpected performance
I'm kinda new to WebGL in general, I've started to make some batching experiences on primitives (just drying a bunch of rectangles by using a combination of two triangles repeatedly).
I've started by ...
0
votes
1answer
176 views
SMFL C++: IntRect intersection not working?
I'm trying to find free space to place rectangles, but even though I check for a collision using .intersects(), it still places them through eachother and somehow doesn't see the intersection ...
0
votes
1answer
109 views
Draw a Texture to fit a rectangle
I would like to draw a texture in a rectangle that is smaller than the texture, normaly the texture will be scaled to fill the rectangle, which results in a squished image. I want to draw it to fit.
...
0
votes
0answers
51 views
How to get many rectangles and join them together into one polygon
I'm using LibGDX to make a platformer game in which I have a tilemap containing lots of instances of a Tile class. From the Tile class you can return a rectangle which represents the tile's position ...
1
vote
1answer
140 views
MonoGame, sprite to rectangle
I'm bucking the trend and working with MonoGame in VB2015, please don't tell me how brilliant C# is and how I ought to learn that, I really can't be bothered, and all the }}{}{{{}{ drives me insane!!
...
1
vote
1answer
114 views
How to combine dynamic asset reload and texture atlases? (rectangle packing with removal)
Usually texture atlases are built either:
as a seperate content pre-processing step
or once when the game starts
What I want to do is create and update atlases on the fly when:
A new texture file ...
1
vote
2answers
85 views
Binding tiles with Rect [closed]
I'm having trouble binding tiles with Rect. I've successfully bound other objects (such as the player, trees etc) in my game with rectangles but I'm unable to do the same with the tiles and I don't ...
3
votes
4answers
253 views
Intersection of a Line and a Rectangle
I have to calculate the intersection of a line segment (represented by 2 points) with a rectangle.
For example:
Axis aligned rectangle corners: (0, 0) (100, 100)
Point 1: (50, 50)
Point 2: (50, ...
8
votes
4answers
1k views
How do I efficiently check if a point is inside a rotated rectangle?
Part for the sake of optimization, part for learning purposes, I will dare to ask: How can I most efficiently check whether a 2D point P is inside a 2D rotated rectangle XYZW, using C# or C++?
...
1
vote
3answers
167 views
What's the most efficient way to find the position of a point in relation to corners of a rectangle despite rectangle's scale
I am struggling to achieve the following with C# (in Unity). I need to find the position of the points that lay at a given distance (let's say 1m) from the corners of a rectangle, in a way that the ...
10
votes
4answers
266 views
How do I interpolate around a rectangle?
I want to make a fancy animation where a point travels around a rectangle. I want to find the point's position at a time t.
The rectangle is given by X, Y, Width and Height.
Is there an algorithm ...
3
votes
1answer
53 views
My intersect detector isn't working
I'm trying to create rooms dinamically by creating them in random places and checking if they do overlap each other. The idea is that if the new room intersects with another one, it must be recreated ...
2
votes
2answers
151 views
Getting the topleft, topright, bottomleft and bottomright points of a shape in Unity3D?
I have a 4-point shape that is defined in screen space by the user.
They can draw the 4 points, one at a time, in any order they wish.
I am using a List of Vector2's to store the screen co-ordinates ...
0
votes
1answer
39 views
Rectangle Collision Not Correct
As you can see on the top corner it says COL: False/True. This is if the player bounds and the tiles which are solids. The rectangles for the tiles and players are checked if they intercept each-other....
0
votes
2answers
635 views
XNA Rotating a Rectangle?
I am in the process of making a giant shooter game and I have got to the point where I needed to use rectangles to detect bullets and giants hitting the player. I did that however, if you look at this ...
0
votes
1answer
356 views
LibGDX collision with rectangle and circle
I have 2 objects, A and B, both are classes with only values, so positions and dimensions are only values (float posX,posY).
I have a render class which render A and B with shapeRenderer; A is ...
1
vote
3answers
626 views
Java 2D Game Hitbox Detection & Rounded Corners
I am working on a simple 2D game with Java, swing and no framework. I have a rectangular player that the user can move around. On the map are few obstacles which the player should not be able to go ...
1
vote
2answers
231 views
SDL draw dynamic select box
this might seem obvious to many, but I'm stuck and I cannot find any tutorial which helped me, so it would be great to find the answer here.
I tried to make a rectangle like you have in RTS games, so ...
0
votes
1answer
119 views
Handling collision with LWJGL rectangles
I'm testing collision with other rectangles so I can implement it into my current project. The problem is the rectangle starts at the right x and y, but I'm not sure where exactly they are. I'm pretty ...
1
vote
3answers
101 views
XNA - How to use One Rectangle in sprites for collisions
I'm new to XNA and game development in general. If I want to make an object solid so my character cannot pass through it, I would use several Rectangles to make the collision more "realistic"
What I ...
0
votes
1answer
73 views
Aligning Camera to Rectangle
I'm working on a game in Java, and I'm having some trouble with finding the correct camera position. I've already made a Rectangle that shows exactly where I want the camera to be, and at what scale:
...
0
votes
1answer
43 views
explaining collision check code
I came across the following code in a game book but I can't get it, does it check if a point ( left,top) in a rectangle?
bool CheckCollision(float left, float top, float SpriteX, float SpriteWidth, ...
0
votes
1answer
96 views
Array Rectangle Collision Handling Inconsistency XNA 4.0 [closed]
I made a simple collision detection prototype.Here's the code for the Player class's collision handler:
public void handleCollision(GameObject OtherObject)
{
if(this.CollidesWith(...
0
votes
1answer
224 views
Best way to go about collision between rectangle and bool array containing pixel data?
Basically, if I have an array along the lines of
bool[] collision;
Filled with a value for each pixel in the sprite I am checking collision against (pixel 1 = true, pixel 2 = false etc), how do ...
1
vote
1answer
70 views
Positioning of AABB / Rectangles
I am wondering what is the best way to position rectangles, the ways I have thought of are:
Have an x and y at upper left, then have a width and height
Have an x and y at upper left, and an x and y ...
-1
votes
1answer
4k views
C# XNA - How to animate using Texture Atlas/ Sprite Sheet
I have a problem which I need to resolve. I am making a Space Invaders game in C# XNA. I've been following this tutorial for the Invaders: https://www.youtube.com/watch?list=LLhsF03QfDMDhbw02_8C6Smg&...
7
votes
4answers
14k views
How to calculate corner marks of a rotated rectangle?
I've got two elements, a 2D point and a rectangular area. The point represents the middle of that area. I also know the width and height of that area. And the area is tilted by 40° relative to the ...
1
vote
1answer
818 views
How do I calculate the distance between a point and a rotated rectangle?
This question is similar to another one about axis-aligned rectangles. However, I specifically want to calculate this for rotated rectangles.
I have a rectangle with a (cx, cy) for the center point ...
0
votes
2answers
134 views
Quick algorithm to identify undrawn rectangles inside a map
I already have a working algorithm for this but it's home-made and there is some redundancy in the things it checks, so I'm looking for a fast algorithm (or the name of it) that would detect undrawn ...
1
vote
1answer
128 views
Why are my sprite outlines partially rendering in the wrong place?
I've been trying to draw an outline around a sprite using the code from this answer.
Details
My sprite is called Ship2Sprite.
This is how I create the rectangle:
rectangle = New Rectangle(...
0
votes
3answers
93 views
If player leaves a rectangle take him back to his previous position
Okay, I'm making a game. The map contains all the blocks/buildings/structures etc... The map is bordered by a rectangle.
So what I want is if the player attempts to exit the rectangle he goes back to ...
0
votes
3answers
159 views
How to find the total bounds rectangle around a list of rectagles
Rectangle object: a simple data structure of 4 floats (w,h,x,y).
I have an array of 2 or more rectangles and want to create a rectangle that surrounds all of them:
The result rectangle, calculated ...
3
votes
2answers
647 views
How can I tell what a rectangle intersects with?
I understand XNA's Rectangle class is rather limited, but surely there is a way to tell what a Rectangle is intersecting with?
If I had Rectangle boundingBox = new Rectangle(stuff here); how would I ...
0
votes
1answer
342 views
How can I determine if an object hit the top of a tile rectangle in MonoGame? [duplicate]
I've been implementing an AI system in my 2D game using MonoGame.
In some situations when a collision between two objects occurs, I need the NPC to move in different directions depending on the ...
0
votes
2answers
838 views
2D Rectangle Collision
I want to make a small 2D game.
In the game you can go in all directions(with the bird's-eye view) and can shoot.
(A little bit like BoxHead http://de.y8.com/games/box_head_2play)
My problem there is ...
2
votes
3answers
298 views
Divide rectangular image into fixed number of random sized rectangles + 1 fixed size rectangle
I'm trying to divide a rectangular image into a fixed number of smaller rectangular image parts (of random but bounded width / height), with the exception of 1 rectangle which is predefined in ...
1
vote
1answer
1k views
Get screen bounds of 3D object
I'm trying to draw a 2D plane that has minimum dimensions to contain a 3D model (a sphere). How do I calculate the minimum size and position of the rectangle to completely cover a 3D model on screen?
3
votes
2answers
137 views
Detecting if a point is inside a rectangle
I have a mouse cordinates in 2D game (x and y) and a rectangle (x,y, width,height).
How to find if the point is in the rectangle? I do not have any code to post here. I'm just searching for help.
0
votes
1answer
1k views
Drawing Text on a scene
I am not sure if I am missing something but I was thinking about how text entities are drawn on a scene, are they drawn with an offset depending on the length of the text? I notice that when I add a ...
1
vote
1answer
147 views
What does Rectangle.Intersect means/do?
Ok I have two rectangles
one is the ball and other is the paddle.
1. if(ball.rectangle.intersects(paddle.rectangle))
y = -Math.Abs(y);
and
2. if(paddle.rectangle.intersects(ball....
0
votes
2answers
701 views
How to properly translate a point by a matrix?
I wrote a simple Matrix class and it has methods like rotate, translate, etc. They all seem to be working, but whenever I try to translate a rectangle using the matrix, the translation axis seem to be ...
5
votes
2answers
335 views
Random 2D point in rectangle, but not in a polygon
I have a static rectangle and dynamic polygon. I need to generate a random 2D point in that rectangle, but not in a polygon. This is what I mean:
Green is where random point can be generated and red ...
1
vote
0answers
275 views
XNA: Placing a “field of view” rectangle on a minimap
I'm building a top-view 3ed person shooter. I have a HUD and in the HUD I have a minimap. I'm trying to draw on this minimap a rectangle which shows me my "visual field", meaning i see on the minimap ...
2
votes
1answer
213 views
Getting a uint color array from a portion of a Texture2D
I'm currently using the Farseer tools to create a body from a Texture2D. However, my texture is a spritesheet and I need to get the uint array containing the colors from a portion of the full ...