Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Oct 2013
Online Last Active Today, 09:32 AM

#5312930 target selection strategies

Posted by on 27 September 2016 - 05:08 PM

If the behavior "makes sense" to the player, we have succeeded.

It's worth noting that what makes sense to the player is something we can (to a certain extent) teach the player during the game.


Imagine a few scenarios:

You're surrounded by enemies, and they all suddenly take cover without warning just before a thrown grenade explodes.

You stealthily take out a guard in a far-off location. As you're looting the corpse, 15 other enemies show up.


Both of those could feel very unfair to the player -- the AI is cheating!


Now imagine the same scenarios, but imagine they are telegraphed to the player.

One of the enemies shout "Fire in the hole!" right before the group of enemies take cover.

You hear radio chatter on the corpse's walkie-talkie, which sounds more and more distressed, before the rescue party shows up.


The AI didn't need to change, but now the game feels a lot more clever, because we've been more explicit in telling the player something which makes the actions make sense to them.


Of course, this isn't always wanted or beneficial, but it's definitely worth keeping in mind.

#5312529 How to get from A to Z (or my first dev blog)

Posted by on 25 September 2016 - 12:20 PM

BTW: If you do want to make a blog, there are developer journals here for exactly that purpose, the forums are just for discussions.

Expanding on this:

Developer journals can be found here: http://www.gamedev.net/blogs

You can create your own here (button to the upper right -- "Create a Journal"): http://www.gamedev.net/index.php?app=blog&module=manage

#5311574 Find angle to get from point A to B with x amount of bounces

Posted by on 20 September 2016 - 03:18 AM

You could shoot in 4 directions, not just 2.


Before morning caffeine, I believe you can do something like this...


In the selected direction, calculate the "effective" end point, as if this were just a huge box, with no bounces.

Basically, add get the distance to the border in your selected direction, multiply it by the amount of bounces, and add that to your endpoint.

Then just get the angle between the start point and that "effective" end point.


EDIT: You might have to add a different distance on odd/even bounces -- (absolute) distance to border in selected direction for odd bounces, (absolute) distance to border in opposite direction for even bounces.

So 5 bounces gives you an effective end point that is offset by (3*absolute_distance_to_border_in_selected_direction + 2*absolute_distance_to_border_in_opposite_direction).

EDIT 2: The previous edit wasn't quite correct -- which you can see in Nanoha's image below, but I think you're able to get a rough understanding of what you need to change in order for it to work :)

#5311517 Unity : OnPointerUp is firing at same time as isPointerDown on UI Button

Posted by on 19 September 2016 - 05:06 PM

Looks right to me, but a thought I had was... is this script attached to multiple things?

#5311450 Two classes relying on each other

Posted by on 19 September 2016 - 11:04 AM

Split things into .h and .cpp files.

Forward-declare classes in the .h where you can, and #include where you have to.


There is no reason for bullet.h having to know the implementation details of aggressive just to have a pointer to the owner.



In bullet.h, just forward-declare aggressive. Also declare the functions for bullet, but don't define them.

In bullet.cpp, include aggressive.h, and do the function implementations there.

#5311190 Game works when built in the IDE, but crashes when I run it from the .exe file.

Posted by on 17 September 2016 - 05:51 AM

that's why I will just keep it this way and not waste time to understand why it works or why it doesn't.

Just changing things randomly is not fixing a bug.


There is a chance the bug was fixed, in which case, you should still understand what caused the bug in order to prevent similar things later.

There is also a huge chance that the bug wasn't fixed, simply masked. If so, what you've done is hide the bug. Currently, you have a guaranteed way of reproducing and fixing it properly (i.e. not by guesswork). If all you've done is hide the bug, it will show up again later. This time, maybe it only crashes once every 10 runs, or sometimes when you press a specific key, or whatever.


You have the option to fix it properly right here and now, and gain some understanding and experience with handling error codes. I would suggest you take advantage of that. 

#5311121 Game works when built in the IDE, but crashes when I run it from the .exe file.

Posted by on 16 September 2016 - 02:08 PM

Yeah, it's because the if statement is always true, and the if-block always tries to access a texture, it doesn't care if there is a texture there or not, and I get a segfault.


I'm still on the opinion that this is a compiler/debugger problem( facepalm from Lactose :lol:  ), because it should notify me when I get segfaults, and not run the game like nothing happened.

To me, it doesn't sound like you know what a compiler does.


Your code is valid, for certain data. Your code is invalid for other data. When it's invalid, it will try to read and use garbage data (random data, can be anything, not guaranteed to be of use or valid for what you're using it for). This is essentially undefined behaviour, and is something you'll always want to avoid.

Sometimes, undefined behaviour will (seem to) work.

Sometimes, undefined behaviour will not work.


Why doesn't it always crash/segfault? Because randomly, the garbage data could be harmless.

Why doesn't the compile catch this compile time? Because the compiler doesn't know what kind of data will run through the code. The data can be files from disk, user input, retrieved from true random generators, etc.


A compiler's job isn't to magically look at all your code and find everything that could be wrong with it ever.

A compiler is (roughly speaking) something which translates the code you've written, into instructions and commands the computer can understand.

This means that you can tell the computer to do something, and make it understand you (compile success!), but what you're telling it to do doesn't work (crash/segfault).


EDIT: This is also why the crashes/segfaults don't occur until the application is running. Until that point, the problem hasn't been triggered yet.

There are loads of horror stories about code that's worked for years, until someone poked in a value that made it all crash -- just changing some data.

#5311088 Game works when built in the IDE, but crashes when I run it from the .exe file.

Posted by on 16 September 2016 - 11:09 AM

I guess there is a problem with the codeblocks compiler

I highly recommend you stop this line of thought immediately.

Compiler bugs are extremely rare, especially for common/simple cases people code every single day.

The problem is in your code. If you can't find it, it's still in your code -- not the compiler.


In my last post I gave you advice to step through/into as much of the code as possible, but you said everything compiles.

This is not what I'm talking about. What I'm talking about is setting breakpoints, which allow you to go through the application line by line and inspect the variables.


When it crashes, you should be able to see exactly which line is causing it. That line + the exact error message will provide you with a lot of information.

#5311082 Game works when built in the IDE, but crashes when I run it from the .exe file.

Posted by on 16 September 2016 - 10:11 AM

Can it be a compiler bug?

Highly doubtful.

Step through (and into) as much as you can, and provide the exact error messages you get, and the line of code that makes it occur.

#5311076 Game works when built in the IDE, but crashes when I run it from the .exe file.

Posted by on 16 September 2016 - 09:35 AM

And one more thing. You're not initializing your Vector/Array.

That's a C# thing, not a C++ thing, I believe? 

#5310736 Frame skips and Object jumps problem.

Posted by on 14 September 2016 - 05:57 AM

Does it also occur if you do not print the frame rate?

The skipping seems to coincide with the frame rate counter updating -- it could be directly linked, or just something else that happens every second.


I'd be tempted to just output the positions every frame to a log, and use information from there to set some conditional breakpoints.

#5309559 space game

Posted by on 05 September 2016 - 04:20 PM

Updates on how your projects are going are very well suited for game dev journals -- you can see what other people have written here:


And you can create your own here:



This forum is mainly for asking questions and getting help with technical questions, and not really for posting status updates on your projects.

#5309152 What to do if I cannot finish my game for a competition before deadline?

Posted by on 02 September 2016 - 06:46 AM

Options are:

1) Prioritize features/content. Keep removing the least important bits until you are able to reach the deadline. Accept that your finished project isn't what you planned originally.

2) Get help creating features/content so you reach the deadline (note: this is often hard/impossible if you are close to the deadline).

3) Accept that you are unable to finish the project in the time given.


In any case, use this as a learning experience when it comes to scope/deadlines and project management.

Things always take longer than you think, even when you schedule for it.


You mentioned you can update later on. Create the most basic version you're able to complete, then add stuff to it with any time you have remaining/available.

#5308456 Splitting an image into chunks of a specified size?

Posted by on 29 August 2016 - 06:29 AM

EDIT: I really need to try harder before asking. Sorry! It was really easy to do, but I just missed it somehow.

Care to share? In case others find this thread by searching :)

#5308329 vector of blocks spawn x and y issue

Posted by on 28 August 2016 - 04:08 AM

It looks like you're trying to set positions every frame (when you draw/update?).

Only set the positions once, e.g. at start-up (or tied to a button press or similar).


You said you wanted to randomly generate x and y, but you never do anything related to random. Here's a reference talking about a simple way to implement random. It also contains links to further reading (<random>).



I'd start there, and try generating random coordinates.

Something you will run into very quickly is the same location being chosen multiple times (causing overlapping blocks), which you will have to deal with somehow.

This can be either by verifying after generating the coordinates that they aren't in use, or maybe having a separate list of coordinates and randomly flag them first before placing, or some other solution.

If you get stuck, post here -- but I would recommend trying to solve it on your own first.