Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 04 May 2009
Offline Last Active Jun 26 2014 06:24 PM

Posts I've Made

In Topic: Trouble Defining Error macro

23 August 2011 - 11:42 PM

Here is a snippet from the header file, the problem is Error c2447 when defining the Message-box macro exasusted my self on this and thought i'd ask for helpski

// Error Handling
#define ERRORWND(msg)
    // Error MessageBox Macro
    MessageBox(NULL, msg, 
        L"Window Initialisation ERROR!", MB_OK|MB_ICONEXCLAMATION);

Any help would be fantastic Also this is and will be complied on Express 2k10 C++


The #define definition finishes at the end of the line. That means the compiles reads the define ( which sets ERRORWND to do nothing) then tries to compile the {. This will cause an errors as the compiler doesn't know how to treat theat block

To solve the problem you need to escape the lines you want the macro to continue over with a \. You need to make sure it is the last character on the line.

// Error Handling
#define ERRORWND(msg)     \
{     \
    // Error MessageBox Macro         \
    MessageBox(NULL, msg,         \
        L"Window Initialisation ERROR!", MB_OK|MB_ICONEXCLAMATION);        \

In Topic: CPU Time in XNA

24 July 2011 - 11:04 PM

I'm playing with Game Studio 4.0 following along in a book and I notice when I run this simple app one of the CPU's is pegged at 100%. I turn on vsync by setting SynchronizeWithVerticalRetrace to true and I'm still running 100% CPU. So I count the updates, draws and time the updates, draws and app time. I get 1385 draws and 1389 updates in 23.652s getting just short of 59 fps as I would expect. I'm taking about 0.1ms to draw a frame and 0.02ms to update it though. Sure, I have two real cores and four pretend ones, but I would rather not heat the cpu needlessly.

How do I get XNA, Game Studio, whomever is responsible from chewing up CPU needlessly?

I personally dont know much at all about XNA, but most games are designed to use 100% of the CPU. I assume that XNA would be the same.

In Topic: [C++] Printing a string character by character.

15 July 2011 - 07:22 PM

I'm going to jump in and suggest that you might want to create a second function that also lets you specify the sleep duration, in case you ever want to do it a lot faster or slower.

Much obliged, I actually have something similar running now.

Another update: work is coming along splendidly, and my interest/motivation for completing this project are quite high. I'm currently stuck on this problem however:

I'm trying to pass the value of the int Profile to the function NewGame(). The idea is that while Profile = 0 (new savegame), the NewGame() function will open up a Savegame menu, and as soon as it's done, will return a value of Profile = 1, allowing the function to progress.

void Intro()
	int Profile;
	Profile = 0;
	cout << "\n\t\t\t\t\t\t";
	sType("...Where the fuck am I?");
	cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t";
	sType("Does it really matter?");
	sType("\n\n\tThis place can be whatever you want it to be.");
	cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t";

void NewGame(int Profile)
	while (Profile = 0)
	void NewSaveScreen();
	cout << "\n\n\t";
	sType("> Welcome to Gears. Would you like to read the tutorial?");
	cin >> TutReq;
	if (TutReq=="Y"||TutReq=="y")

You might see something I don't here; for some reason, the program will jump over the "while" statement (tried using if/else as well) and go straight to system("cls") in the NewGame() function. I tried using cout to determine the value of Profile both before and after being passed off from the first function to the second, and both values are 0 as they should be.

Any ideas?

Your problem in in the line while (Profile = 0) what this does is it assigns the value of 0 to profile. What you need to do is change it to while( Profile == 0 ). == is used to compare values in c++

Good Luck

In Topic: Zooming onto an arbitrary point

27 January 2011 - 03:10 AM

I cannot for the life of me figure out this seemingly simple problem.

I'm trying to figure out how to zoom onto a 2D point, and reposition the camera accordingly.

Let's say my current screen space is this gray box, with the top left corner x1, y1. I want to zoom in on that red dot, at Fx, Fy, with zoom amount Z. The resulting screen space should be the blue rectangle. How do I find x2, y2?
Posted Image

Now I've been able to figure out the math of this. It should be:
x2 = x1 + Fx / Z
y2 = y1 + Fy / Z
Right? But it seems to fall apart when zooming out, or when I zoom in again. Zooming out still increases it, since Z is always a positive number. Zooming in multiple times has all sorts of issues.

This seems like a very basic operation, yet I've spent many frustrated hours trying to get it to work. My drawing code works fine. I can pan the image, and I can zoom onto point 0,0 without any issues. So theoretically, zooming onto point F would be the same as zooming onto point 0,0 and panning it to F, right?

Thanks for any help.

I haven't tested this, but you could try this.

ix1 = initial x top left
iy1 = initial y top left
ix2 = initial x bottom right
ix2 = initial y bottom right
Fx = Focus X
Fy = Focus Y
MaxZoomX = is the limit of the zoom
ZoomLevels = Max levels of zoom

new screen is (x1,y1) (x2,y2)
x1 = ix1 + ( Fx - ix1 )/ZoomLevels*z
y1 = iy1 + ( Fy - iy1 )/ZoomLevels*z
x2 = ix2 - ( ix2 - Fx )/ZoomLevels*z
y2 = iy2 - ( iy2 - Fy )/ZoomLevels*z

In Topic: Melee Miss Probabillity

26 January 2011 - 10:29 PM


I want characters in my game to hit a target more often as their agility increases. I want their agility to be 50% at level 1 and 100% by level 99. Does anyone know a formula for this? I have this, which is fine if I wanted 1% accuracy at level 1:

bool hit = get_random_between(0, skill + (99 - skill)) < skill;

1000 samples for each level gives:


How about
bool hit = get_random_between(0,99) < (   39.0f* log10( skill + 5) + 22 ) ;

Look at the Graph