# TTTNL

Member Since 03 Oct 2012
Offline Last Active Yesterday, 02:19 PM

### Visual Studio 2012 errors

15 April 2013 - 03:36 PM

I downloaded Visual Studio 2012 just to see how it works and if it's worth updating to from Visual Studio 2010. Running in Release mode works fine but in Debug mode it gives me errors:

What can i do to solve this? Thanks

btw VS 2012 looks great.

### Who on this forum is applying to IGAD this year?

14 April 2013 - 12:14 AM

I've been learning to program since last November using the well known tutorials on this website. Like many of you know i have been spamming posting on this forum with a lot of topics about specific programming things, but i haven't seen a lot of topics from others who are doing these tutorials. The deadline for the programming assignments for the IGAD study course is th 17th of May so there is only about a month left to submit.This made me wonder if i am just that bad unskilled or if there are even other people doing these tutorials? I do see a lot of views on all of the topics i made, so i guess the information is being used. Comment if you are doing the tutorials or applying to IGAD this year and tell something about your experience with the tutorials.

### Reading a textfile

20 March 2013 - 06:38 PM

I'm trying to implement a settings file and have the program get the variables from that file. The file looks like this:

UIx1: 0
UIy1: 0
UIx2: 0
UIy2: 0
Bullet Delay: 20
First level: 1


And the piece of code that retrieves the data:
settingsfile = fopen( "settings.txt", "r" );
if (settingsfile != NULL)
{
fscanf( settingsfile, "UIx1: %i UIy1: %i UIx2: %i UIy2: %i Bullet Delay: %i First level: %i", &UIx1, &UIy1, &UIx2, &UIy2, &bulletDelay, &startlevel );

fclose( settingsfile);

}
else
{
printf("Could not open the file.\n");
}


But isn't there a simpler, better readable way to get that information, with a few settings extra that code is going to look (even more) awful.

### tutorial 17: File I/O

16 March 2013 - 01:53 AM

So as i'm doing part 17 of the devmaster tutorials, i encounter this piece of code:

FILE* f = fopen( "settings.txt", "r" );
fget( f, "xpos = %f", &x );
fclose( f );


When i paste this in Visual Studio 2010 it generates an error with "fget" because it is undefined. I searched through my entire project and "fget" is nowhere to be found, however i can find these:
-fgetwc
-fgetwchar
-fgetws
-fgetwc_nolock

and some others

i tried to google "fget C++" but it doesn't even seem te exist. How can i work around this problem?

### Aiming and shooting in a 2D game

09 March 2013 - 07:52 PM

So if you followed my previous posts you may know i have got my bullets implemented thanks to you guys and did some work to optimize it a bit. I added an ammo variable and changed the container for the bulletclass from a vector to an fixed size array. And using a for loop that will put every bullets' "active" boolean to false if it's of the screen. So there are only 12 bullets (because of the use of an array) but since every bullet that's off the screen gets put to non active i can use it again when needed, see my code below

spawning a bullet

for (//loop through bullets)
{
if ( bullets[i].active == false )
{
bullets[i].active = true;
bullets[i].x = (player.x + player.rad - bullets[i].rad); //Middle of player bubble
bullets[i].y = (player.y + player.rad - bullets[i].rad); //
player.ammo--;
break;
}
}


checking if it's of the screen

for ( //loop through all bullets)
{
if (//bullets[i].x or bullets[i].y out of screen)
{
bullets[i].active = false;
}
if (bullets[i].active == true)
{
bullets[i].move();
bullets[i].draw( m_Screen );
}
}


After reading a tutorials on this site which involved working with the mouse i used that so it draws a line between the middle of my player bubble to the mouse x and y coordinates (blue line in screenshot).

Currently the bullets are just travelling downwards to face the upcomping horde of bubbles, but now i want to be able to shoot the bullets towards the end of the line and keep them moving towards that point even if the mouse has moved. I tried to do so with slope values and such but i can't get my head around the maths that is needed here.

If i click, it spawns a bullet at my player's x and y coordinates. I have added a variable which can hold the direction for every bullet object but i don't know how to get that direction and how to keep a bubble moving towards the point that i defined with the cursor when i clicked.