Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Oct 2013
Offline Last Active Yesterday, 06:04 PM

#5298247 The latest BMP I made crashes the program, other BMPs work fine

Posted by Lactose! on 27 June 2016 - 09:38 AM

It sounds like the crash is due to dereferencing a null pointer (since you could create an error message checking image == null). This is not the same as the image loader crashing your application.
The loader is probably failing to load the image, returning a null pointer, and your application doesn't handle this case properly.
One of the most common reason for failing to load an image is typing in an incorrect filepath/filename, so you should triple check that it's correct. Even if you're sure it's correct, check again.
Other than that, step through in a debugger and see where things go wrong.
Some additional advice;
Refer to the documentation to see what a function should return, and what is returned in the case of an error.
With that in mind, do error checking whenever possible. (For SDL this is usually checking for a null pointer and then calling some xxx_GetError function).
If you have problems with your code, post your code. Don't make us guess what might be the problem.
Learn how to use a debugger. This is a skill you will need as you progress. The sooner you learn, the better.

#5297442 Breakout Animation for bricks.

Posted by Lactose! on 21 June 2016 - 07:38 AM

You could replace the "shown" variable inside brick with a "hiddenTimer" or something -- an initialize the timers so that the top-left one has a short timer and the bottom-right has a long timer.

When updating, decrement the hiddenTimer for each brick.


Then, when drawring, instead of "if (brick.shown)" you could do "if (brick.hiddenTimer < 0)".

#5297376 How to make a monitor?

Posted by Lactose! on 20 June 2016 - 03:43 PM

Render to a texture, and apply that texture to the monitor.


My internet is being super shoddy due to bad weather, or I'd try to find some links. Googling based on what I said should get you started.

#5296525 3D 8 directional sprite rotation based on facing direction relative to camera...

Posted by Lactose! on 14 June 2016 - 03:25 PM

arctan parameter order is usually (y, x) -- not (x, y).


Apart from that, I'd suggest just printing out some debug values as you spin the camera to see what values you get and compare them to what you are expecting to get, noting/looking into cases where the two differ.

#5296475 How to make spot lights in darkness for 2D games

Posted by Lactose! on 14 June 2016 - 08:18 AM

Very very useful tutorial : http://ncase.me/sight-and-light/ 


Fixed link: http://ncase.me/sight-and-light/

(Space was included at the end, causing a 404).

#5295950 Why didn't somebody tell me?

Posted by Lactose! on 10 June 2016 - 06:53 AM

Something I've known for a long time and thought everyone knew:


When using Chrome, you can press Ctrl-Shift-T to reopen tabs you've just closed.

I wrote this on the previous page! Post #122

#5295144 2d animation using unity

Posted by Lactose! on 05 June 2016 - 03:57 PM

You either need to create multiple images for each animation, or use another tool to create this specific type of animation for you.

If you create the images yourself, each image of the animation is called a frame, and you'll need to create as many frames as there are changes in the graphics. You then need to, in code, drive that animation (by telling the object which image it should be using, based on e.g. elapsed time, or something else).

(Note that the different frames can be either 1 image per frame, or 1 big image containing all the frames in the animation.)


There are also certain changes you can do directly in Unity with a single graphic -- scaling and rotating spring to mind.


If you choose to use a different tool to create the animations, check out Spine. I'm not entirely familiar with the details of it, but it can be used in Unity and seems to fit the animation style you mentioned.


Maybe I should have gpogled my question

Yes, you should. If you want to make a game, you can't be too lazy to do a bit of research on your own. Especially given how just putting your subject into Google brings up quite a lot of relevant hits.

#5294530 Building a game like "Game of War"

Posted by Lactose! on 01 June 2016 - 02:52 PM

Would anyone be interested in helping to build the game?

Recruiting goes in the Classifieds section of the forums, not here.


If it were as simple as you say, then games wouldn't take as long (and require as many people) as they do. It doesn't matter how smart you are (or think you are), games are a lot more work than you give them credit for. Multiplayer games even more so. MMOs even more so, much much more than you believe.


Can you give any reasonably explanation as to why similar games have development times measured in years, with production teams measured in tens of people, if it were as easy as you think it is?


Unity will not be enough. Once you have all the assets you need, you can use Unity to put them together and make them do as you want, but in order to create and potentially process/adjust all the assets (images, sounds, etc etc), you will need other software (e.g. Gimp, as was mentioned).

#5293193 Confused About Frames Per Second

Posted by Lactose! on 24 May 2016 - 06:40 AM

you only need a solid 15 fps to be sufficiently responsive to be playable. once you hit 30 or so, your animation is smooth and your responsiveness is quite snappy. anything more is just smoother animation eye candy. turns out that lower framerates (within reason) aren't bad, variable frames rates are bad.

This reads like an absolute truth, but it isn't; it depends wildly on the game. While the games you make might be fully playable at lower framerates (and might also thus be what you're accustomed to), it does not mean that translates to every other game/genre.

For fighting and racing games in particular, higher framerates are easily noticable, far above 30 frames per second.

For a chess game without fancy movements/animations, 2 frames per second would probably still be playable (although possibly somewhat annoying with selection latency).

I can't think of a single instance where a higher frame rate would lead to a worse product, but I can definitely think of the inverse.


For VR games/applications, what is considered to be usable is also much much higher, although not for the same reasons.


That said, I definitely agree with constant frame rates being very important. Companies are also starting to catch on to this, e.g. by offering optional frame rate limiters if the frame rate varies, and even in some cases options for whether graphics quality or frame rate is to be prioritized (both of which, for console games, are a fairly huge change to the status quo).

#5293096 Looking for experience?

Posted by Lactose! on 23 May 2016 - 01:04 PM

Check out the Classifieds.

#5292943 SDL and Frame Timing

Posted by Lactose! on 22 May 2016 - 04:48 PM

I highly recommend the following article. It's related to the frame timing issues you were having here, and it might save you a lot of problems later on, when it comes to game logic, etc.

Fix Your Timestep!

#5291952 Determine what side of rectangle is hit by ball

Posted by Lactose! on 16 May 2016 - 03:39 PM

There are some mistakes in your conversion (notably: "t" without a number is not currentDeltaTime, it is the time at which the collision occurs). Your current code would always have k = 1*.


The magic f is just a variable that exists solely to ensure that a line segment is output instead of an infinite line.

However, I still have a feeling this is a lot more complicated than it probably needs to be.


*or divide by zero if currentDeltaTime and prevDeltaTime were equal.


While there might be edge cases where the following is not true, I would imagine this would work in most simple cases involving linear motion, and it should be fairly quick to implement/test:


Keep track of the ball's previous position (i.e. last frame's position) and the paddle's previous position, and whether a collision occurred in the previous frame.


If an intersection occurs, and there was no intersection in the previous frame, compare the positions of the paddle and the ball in the previous frame.

If the ball was to the left of the paddle in the previous frame, collision occurred on the left side of the paddle. Conversely, if the ball was to the right of the paddle before the collision occured, collision occured on the right side of the paddle.

#5291913 Plane equation, + or - D

Posted by Lactose! on 16 May 2016 - 12:44 PM

Randy is saying that we can make D be positive by doing essentially this...



Ax + By + Cz = d

Substitute -d with D


Ax + By + Cz - d = 0

Ax + By + Cz + D = 0

Ax + By + Cz + -(Ax + By + Cz) = 0


It doesn't change the result, it just adds a few parenthesis or sign changes through-out.

In some cases this might make it easier to do some math, or to remember it, or some other reason. The result stays the same, though.


EDIT: Typo.

#5291344 Where to start in game programming?

Posted by Lactose! on 12 May 2016 - 04:49 PM

Hello and welcome.


I recommend you start with the FAQ.

#5291324 Need some help on where to start

Posted by Lactose! on 12 May 2016 - 02:08 PM

Hello and welcome.


I recommend you start with the FAQ.