• Content count

  • Joined

  • Last visited

Community Reputation

231 Neutral

About taliesinnz

  • Rank
  1. Trouble Defining Error macro

    [quote name='Spawn0' timestamp='1314163597' post='4853087'] [font="arial, verdana, tahoma, sans-serif"][size="2"] 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[/size][/font] [code] // Error Handling #define ERRORWND(msg) { // Error MessageBox Macro MessageBox(NULL, msg, L"Window Initialisation ERROR!", MB_OK|MB_ICONEXCLAMATION); } [/code] Any help would be fantastic Also this is and will be complied on Express 2k10 C++ Thanks Adam [/quote] 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. [code] // Error Handling #define ERRORWND(msg) \ { \ // Error MessageBox Macro \ MessageBox(NULL, msg, \ L"Window Initialisation ERROR!", MB_OK|MB_ICONEXCLAMATION); \ } [/code]
  2. CPU Time in XNA

    [quote name='LilBudyWizer' timestamp='1311567499' post='4839843'] 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? [/quote] 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.
  3. [C++] Printing a string character by character.

    [quote name='3lement' timestamp='1310777468' post='4835855'] [quote name='SkoobyD00' timestamp='1310608489' post='4835087'] 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. [/quote] 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. [code]void Intro() { int Profile; Profile = 0; system("cls"); cout << "\n\t\t\t\t\t\t"; Sleep(3500); sType("...Where the fuck am I?"); Sleep(5000); system("cls"); 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?"); Sleep(3500); sType("\n\n\tThis place can be whatever you want it to be."); Sleep(6000); system("cls"); cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t"; Sleep(3500); Gears(); NewGame(Profile); }[/code] [code]void NewGame(int Profile) { while (Profile = 0) { void NewSaveScreen(); NewSaveScreen(); } system("cls"); cout << "\n\n\t"; Sleep(3500); sType("> Welcome to Gears. Would you like to read the tutorial?"); cin >> TutReq; if (TutReq=="Y"||TutReq=="y") { Tutorial(); } else Beginning(); }[/code] 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? [/quote] Your problem in in the line [i]while (Profile = 0)[/i] what this does is it assigns the value of 0 to profile. What you need to do is change it to[i] while( Profile == 0 )[/i]. == is used to compare values in c++ Good Luck Taliesin
  4. Zooming onto an arbitrary point

    [quote name='lifeformed' timestamp='1296114020' post='4765507'] 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? [img]http://i.imgur.com/uq3r7.png[/img] 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. [/quote] 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
  5. Melee Miss Probabillity

    [quote name='Mybowlcut' timestamp='1296098472' post='4765425'] Hey. 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: [code]bool hit = get_random_between(0, skill + (99 - skill)) < skill;[/code] 1000 samples for each level gives: [attachment=1197:untitled.png] Cheers. [/quote] How about [code] bool hit = get_random_between(0,99) < ( 39.0f* log10( skill + 5) + 22 ) ; [/code] [/code] Look at the [url="http://fooplot.com/index.php?&type0=0&type1=0&type2=0&type3=0&type4=0&y0=39*log%28%20x%20%2B%205%29%20%2B%2022&y1=&y2=&y3=&y4=&r0=&r1=&r2=&r3=&r4=&px0=&px1=&px2=&px3=&px4=&py0=&py1=&py2=&py3=&py4=&smin0=0&smin1=0&smin2=0&smin3=0&smin4=0&smax0=2pi&smax1=2pi&smax2=2pi&smax3=2pi&smax4=2pi&thetamin0=0&thetamin1=0&thetamin2=0&thetamin3=0&thetamin4=0&thetamax0=2pi&thetamax1=2pi&thetamax2=2pi&thetamax3=2pi&thetamax4=2pi&ipw=1&ixmin=1&ixmax=99&iymin=0&iymax=100&igx=10&igy=10&igl=1&igs=0&iax=1&ila=1&xmin=1&xmax=99&ymin=0&ymax=100"]Graph[/url]
  6. Decltype and template help

    Quote:Original post by u Tried this on my GCC, got this: test.cc:30:32: error: invalid use of non-static member function 'int Bar<Foo>::returnsomething()' test.cc:30:32: error: no matching function for call to 'getsomething()' Changed this line:auto getsomething() -> decltype( Bar< T >::returnsomething )to:auto getsomething() -> decltype( Bar< T >().returnsomething() ) and it compiles fine. Proper error message FTW. Yay! It is now working on MSVC too. I guess more brackets the better. Thanks
  7. I am using MSVC2010 and getting a strange error struct Foo; template< typename T> class Bar { } template<> class Bar< Foo > { int returnsomething() { return 1; } } template< typename T> auto getsomething() -> decltype( Bar< T >::returnsomething ) { Bar< T > t; return t.returnsomething(); } main() { cout << getsomething< Foo >() << endl; } MSVC gives me an error C2893: Failed to specialize function template ''unknown-type' I have read the help but not sure what it mean to my code. Can someone enlighten me? Thanks
  8. A DB Conundrum...

    I am no expert but this is a simplified version of what I would do if doing something similar. Users -------- ID (auto increasing unique key) Name ... Resource Table -------------- ID (auto increasing unique key) OwnerID (linked to Users.ID ) ... Groups ------ ID (auto increasing unique key) UserID (linked to Users.ID ) Name GroupMembers ------------- GroupID (linked to Groups.ID ) MemberID (linked to Users.ID ) Permissions ------------ ResourceID Type ( 1 for Group, 2 for User ) AccessID ( linked to either Users.ID, or Groups.ID ) CanView ( 1 for allowed, 0 for not viewable ) CanComment( 1 for allowed, 0 for not ) ... then when you want to get a list of items you just have to do something like this ( not tested ) SELECT * FROM Permissions LEFT JOIN Groups ON Permissions.AccessID=Groups.ID LEFT JOIN GroupMembers ON Groups.ID=GroupMembers.GroupID WHERE Permissions.ResourceID=<RESOURCE_ID_HERE> AND ( ( Permissions.Type=2 AND Permissions.AccessID =<USERID_HERE> ) OR ( Permissions.Type=1 AND GroupMembers.MemberID=<USERID_HERE> ) )
  9. Stupidly stuck on writing to a file :(

    Does using open( "%USERPROFILE%\\Desktop\\..."); help at all
  10. how something along the lines of SELECT * FROM TableA LEFT JOIN TableB ON TableA.ID=Table.ID WHERE ( TableB.Status=Fixed AND TableB.ReadyToShip=True ) OR TableB.AID IS NULL
  11. how about namespace MyFramework { #ifdef OPENTK typedef ::opentk:vector2 vector2; #else typedef ::slimdx:vector2 vector2; #endif }
  12. Cryptographically secure p2p network?

    [quote]Original post by dascandy That only holds if you can survive the max RTT around the world for one game update packet, plus some 40% or so for certainty. 20000 km at about 200000km/s (speed of light in metal) is 0.1 second for a message. That's 6 game cycles. Allowing 9 is sufficient for this to work, even with a little packet loss. It does mean that a ping of over 150 single-trip (or 300 round-trip) will end the game immediately. [quote] Just though I would let you know, a ping to my gateway alone takes me 150ms.. So any game that I join will almost certinally "end the game immediatly".
  13. Using structs for network packets

    This method could cause problems when sending packets accross platforms, or even to the same program compiled by different compilers. This will be due to different OS/platforms/compilers packing data differently, using different endians etc..
  14. Pointer to an array of pointers

    Quote:Original post by slicer4ever no no, what ur doing means their's no reason for me to create the pointer D, what i want is such that D points to what Ind does, but as single values i.e: D[0] = Ind[0][0] = Pnts[0]; D[1] = Ind[0][1] = Pnts[1]; D[2] = Ind[0][2] = Pnts[2]; D[3] = Ind[1][0] = Pnts[3]; ... if this is the case could you just not do something like this? float Pnts[12] = {x,y,z, x+Width, y,z, x+Width,y+Height,z, x,y+Height, z}; float Ind[4][3]; &Ind = Pnts; for( int i = 0; i < 4; i++) { printf("%f %f %f\n", Ind[i][0], Ind[i][1], Ind[i][2] ); }
  15. Preserving 1:Many Relationships in DB

    What MNicholson described was a many-many relationship, so any number of cars can have any number of drivers. For a 1-many relationship is becomes slightly simpler. From you example for every car there is many drivers. You had the right idea driver_ids field however you made the mistake of putting it on the wrong table. Since each driver can only have 1 car, then you can add car_id to the drivers table. The [cars] table might look like this: [cars].[car_id] --> the unique ID (primary key, auto-inc, etc.) [cars].[car_year] --> year car was made The [drivers] table might look like this: [drivers].[driver_id] --> primary key auto integer ID [drivers].[driver_first_name] [drivers].[driver_last_name] [drivers].[car_id] And so, one particular car record might have the following field values: [cars].[car_id] = 1 [cars].[car_year] = 2005 [drivers].[driver_id] = 1 [drivers].[driver_first_name] = driver [drivers].[driver_last_name] = 1 [drivers].[car_id] = 1 [drivers].[driver_id] = 2 [drivers].[driver_first_name] = driver [drivers].[driver_last_name] = 2 [drivers].[car_id] = 2 [drivers].[driver_id] = 3 [drivers].[driver_first_name] = driver [drivers].[driver_last_name] = 3 [drivers].[car_id] = 1 In this example "driver 1" and "driver 3" both drive "car 1" while "driver 2" drives "car 2"