SOLVED Insane Visual Issues

Hello1423

Member
My game has insane visual issues after leaving it running for a couple of hours.

The issues are everywhere, these are some examples:

draw_circle starts drawing circles wrong
sprites are drawn at wacky angles or are skewed strangely, sometimes even the top half of a sprite will be drawn at a different angle than the bottom half of it

I have never seen this before, I mean how is it possible that draw circle starts failing to draw circles correctly?
1605400200425.png
That green area in the center is this code from the object I use to control the camera:
GML:
draw_set_color(c_lime)
draw_circle(x,y,10,false)
And the red/black circle and green circle behind it are drawn similarily at the mouse location.

You can also see in that image how only part of the left bunk bed sprite is being drawn correctly, while on the right it is being drawn correctly. That is the same exact sprite, I wouldn't even know how to replicate that effect if I wanted to.

Here is a gif showing off how strange it all is.

Now during the time I left the game running, the ship that the camera is following is moving off in a random direction. Can gamemaker not handle draw events that occur far away from 0,0?
 

flyinian

Member
I recommend posting your camera codes and draw codes that are in question so, someone can help you more. As well as a screenshot on how its suppose to look.

Your computer may had a hard time running your game for 2 hours and gave up and rendered your game funky. Just a guess.
 

Hello1423

Member
Circle Issues.png
Top is after running for a while, bottom is after restarting the room.

Here is the part where the camera info is set in the end step event:
GML:
camera_set_view_pos(camera, (ship_cam_x-zoom_width/2), (ship_cam_y-zoom_height/2))
camera_set_view_angle(camera, -selected_ship.angle)

camera_set_view_size(camera,zoom_width,zoom_height)
The circles are drawn with either the draw_circle or draw_circle_color functions like this for the center green circle:
Code:
draw_set_color(c_lime)
draw_circle(x,y,10,false)
 

TheouAegis

Member
Dis you say your ship is to the left or above the room itself? So x and y are negative? That could be an area of contention for draw_circle().

Simple test that doesn't require 2 hours:
if keyboard_check_pressed(ord("Y")) {x=-x; y=-y;}
Run the game, press Y, see if the circle corrupts (or uncorrupts) with each press of Y.
 
N

natanlidukhover

Guest
Dis you say your ship is to the left or above the room itself? So x and y are negative? That could be an area of contention for draw_circle().

Simple test that doesn't require 2 hours:
if keyboard_check_pressed(ord("Y")) {x=-x; y=-y;}
Run the game, press Y, see if the circle corrupts (or uncorrupts) with each press of Y.
That can't be the solution since the issue arises in multiple spots other than draw_circle(). All sprites in his image(s) look skewed or are otherwise screwed up, not just the ones using draw_circle(). I have no idea what could cause such an issue. The fact that this issue only arises after the game runs for a prolonged period of time is odd as well; if there were an obvious bug in the code, why would the drawing issues not occur right away?
 

Hello1423

Member
Dis you say your ship is to the left or above the room itself?
Just being in a location to the top left of 0,0 does not immediately cause any of the issues, if that is what you mean.

Any possibility of shaders affecting the drawing by moving pixels to be drawn around?
I am not using any shaders in the game yet.


What CPU/GPU are you using? Have you tried running monitoring software while running the game?
My computer has the following:
Intel Core i7-4790K CPU
NVIDIA GeForce GTX 1060 6GB
16 GB RAM

What do you mean by monitoring software? I don't think the issue would stem from my computer beginning to fail or overheat because just hitting R to restart the room instantly resets all issues.
 
My computer has the following:
Intel Core i7-4790K CPU
NVIDIA GeForce GTX 1060 6GB
16 GB RAM

What do you mean by monitoring software? I don't think the issue would stem from my computer beginning to fail or overheat because just hitting R to restart the room instantly resets all issues.
OK, just wanted to rule that out as a possibility.
 

TheouAegis

Member
Force your ship to various extreme coordinates, both positive and negative and try to recreate it at those extreme coordinates. Or wait many hours again. Then check what coordinates the issue is occurring at. Room coordinates should not affect things - they're just numbers - but weirder things have happened in GM's history.
 

RujiK

Member
I'm pretty confident you are running into floating point inaccuracies. the accuracy of a float (aka numbers with decimals) in GMS is based on it's size.

So small numbers can have like 10 decimal places and remain reasonably accurate, but larger numbers may only be able to have 5 point of accuracy. REALLY large numbers won't even be able to have decimals at all!

So if you have a number like ...999,888.525, it may round up to ...999,889 or even just ...999,890.

The maximum stable INTEGER in native GM numbers is 18,014,398,509,481,983 (2^54 - 1). If you go any higher than that the math gets really weird. Like if you add 10 it will only add 8 in reality. So when you are drawing at these large numbers, the drawing coordinates are inconsistent and you get this jarbled mess. (Note that you will start to lose decimal accuracy far before you hit 2^54, and your drawing may get messed up much sooner)
 
Last edited:

Hello1423

Member
After doing more testing it does seem like it all comes down to the coordinates. The farther away from 0,0 in any direction something is drawn, the more weird things happen and the more severe the weird things look.

For example, by an x of -10000000 circles drawn with draw_circle sometimes appear like this:
1605569873725.png
They are a little bit off. And it just gets worse with greater distance.
Positive and negative positions don't change anything.
Here are the circles around x = 20000000:
1605570205087.png

I guess the conclusion is that I need to add something to the game that keeps the player near the origin of the room, since gamemaker stops drawing things correctly when very big numbers are involved.
 
Last edited:

TheouAegis

Member
Do you even need to move the ship? I'm not sure what kind of game / program you are making, but consider instead of changing x and y over time, change two other variables of your own instead and leave x and y intact so that all drawing will be handled on the assumption that the coordinates are (0,0) in the top left.
 

kburkhart84

Firehammer Games
There are different ways of handling. These two come off the top of my head, though there are others I'm sure.

1. Simply never move your ship, rather move everything else around it. It seems tedious, but its been done before, and you can use parent objects to get that code into one place if you want.

2. Move the ship like normal, but at certain intervals just return back to the origin. Like once X gets over 10,000, just move every single object back 10,000 so you are at the origin again along with all the objects.
 

Hello1423

Member
I don't think that moving the universe around the ship will work, because there can be many ships at the same time.

2. Move the ship like normal, but at certain intervals just return back to the origin. Like once X gets over 10,000, just move every single object back 10,000 so you are at the origin again along with all the objects.
This is a good idea, thanks. I think I will have both this and I will reset positions when the player docks at a station.
 
Top