Sodabread 88 Posting Whiz in Training

The answers, as always, is: it depends. Databases are often times best with online/browser based games, but Flash, I believe, can write save files to the computer on which it's being played. I don't work with Flash, so I'm not 100%.

In single-player, offline games a save file would probably be the best, as you don't really want to install a database instance for your game. I can't say I'd be ok with someone installing SQL on my machine just to save a game. Although, you can do a persistent/occasional network connection (which puts it in the online game category) in order to write the data to a database on your end.

Figure out what you want your game to be and how the player should be able to play it and you'll most likely have your answer.

neartoyou commented: Good analysis +0
Sodabread 88 Posting Whiz in Training

I'm working with SDL & C++ at the moment, so I'll take a look at the video & pastebin when I get home tonight as I can't get to it at work. I had a similar issue when I first started, so maybe I'll notice something that fixed it for me.

Sodabread 88 Posting Whiz in Training

one recommendation i would make.. you have several lines of beep(900,100). i would advise creating two int's that will hold these values. for example:

//instead of 
beep(900,200);

//try
int frequency = 900;
int duration  = 200;

beep(frequency, duration);

that way after you got your program up and running.. and you want to tweak its performance, all you have to do is change the value of two variables instead of editing hundreds of lines of code.

Even better, use 3 ints: freq, short_beep & long_beep. Morse code only has 2 lengths and a frequency of the beep, so this covers you for the whole shebang.

Sodabread 88 Posting Whiz in Training

For C-style file i/o, look into FILE *s and how to use them.

For using pointers with functions, write the function so it accepts a pointer and pass a pointer one of a few ways:

void stuff(int *x)
{
   *x = 4;
}
int main()
{
   int x;
   int *y;

   stuff(&x);
   stuff(y);
}
Sodabread 88 Posting Whiz in Training

It's cool. It always just seems that non-native english speakers get almost every other word right except 'please'.

Best of luck and welcome to DaniWeb =)

Sodabread 88 Posting Whiz in Training

1. The x variable doesn't exist in the change function. The function should accept an int reference if you want to change it in the func, then pass x in.

void change(int &x);
int main()
{
   int x = 4,y;
   ...
   change(x);
   ...
   return 0;
}
void change(int &x)
{
   x = x + 4;
}

2. YOU write C programs to do all that stuff, come back with actual questions and we'll do what we can to help.

Also, for future reference, post the errors you're getting with your code. The more you do to tell us what your issue is, the more likely we are to help you. Oh, and "plz" isn't a word.

Sodabread 88 Posting Whiz in Training

It all depends on how much work you want to do and/or how much time you want to spend learning something else.

If you want something up and running super quick, I think Unity would be your best bet, but Torque can still get the job done. Unity has a full on 3D editor which will allow you to build your house layout in the editor, and compile that as your application, then just walk through it. I haven't used it much, but I believe that's how it could work for a simple application like you have.

Ogre3D is purely graphics (and comes with OIS, which is used for input), which will work, but you'll need to build your house layout in another application (such as Blender or Milkshape) and load it into your application. You can find plugins for popular 3D applications which will allow you to export your objects directly to the .mesh format, which is what's used in Ogre.

As far as what you're looking to do, I think Unity or Torque would honestly be your best bet to get something up and running super quick. Check them both out & decide what you like best.

Hope that helps.

faroukmuhammad commented: Awesome explanation +2
Sodabread 88 Posting Whiz in Training

They don't need to "get into the protocol", whatever that means. All they need to do is pull the right strings to get the host to shut the site off. Not much can be done to defend against that.

Chances are, happygeek is correct and the EDL just sucks at the internet.

happygeek commented: correct :) +0
Sodabread 88 Posting Whiz in Training

For an easy library to get up and running, check out Ogre3D for graphics.

If you're looking to do even less work, you can check out Torque & Unity, as they're fully featured game engines, so you can just add your geometry (walls, floors, ceilings, etc..) and build and run.

Sodabread 88 Posting Whiz in Training

WriteLine automatically adds a newline character. Write, on the other hand, does not.

Console.Write("");
Console.ReadLine();
Sodabread 88 Posting Whiz in Training

Ah. My bad. I read it wrong the first time.

From the documentation for FreeGlut, it looks like it's not possible to do it on mouse button release as Tao only uses the 3 mouse buttons regardless of state. You would be able to create your own menu and call it to begin drawing on a button's release, but that also kind of partly defeats the purpose of using the Tao framework, at least for menus.

daniel955 commented: Good +1
Sodabread 88 Posting Whiz in Training

The easy answer is physics & "soft" targeting. Apply your x/y/z acceleration to the object, having it move toward the current node/point/target and once it gets within a pre-defined distance to that target, set it's new target to the next point and accelerate the object toward that new target. This should give a smooth transition, as long as you're not using a pure xVelocity = 2.0 type statement, but positive & negative acceleration.

Sodabread 88 Posting Whiz in Training

We don't just post code for people that ask for it. You need to do the work on your own, then come in and ask us for help on specifics if/when you get stuck.

In other words, we'll help with homework, but we won't do it for you.

Sodabread 88 Posting Whiz in Training

It's not about negativity, it's about reality. The gaming industry is a very difficult one to thrive in unless you have the talent to back up everything you want to do. This is why just having a cool idea for a game is going to do next to nothing for anyone. The person with the idea needs to have one of the skills necessary to build the game, whether it be business sense, game design (not game idea think tanking), programming, etc... Like I said, game ideas are a dime a dozen, but you're going to need something else to back it up if you want to put a team together. The only way most people are going to do all the work on something that isn't their idea is if their getting paid for it.

DragonReeper commented: I tottally agree, but nobody knew better when they started out +0
Sodabread 88 Posting Whiz in Training

Is the ball collision volume an AABB (axis-aligned bounding box) or is it a circle (I'll assume AABB)?

If it's an AABB, you'll want to compare opposite sides of the ball and the brick, then reverse the velocity of the ball from the direction it hit:

if(ball->right >= brick.left && ball->top <= brick.bottom && ball->bottom >= brick.top)
    ball->yVelocity *= -1;

When checking for different sides, start with one side, then check against both perpendicular sides, then repeat for all 4 sides. Determine which sides here have collision, then take those sides and figure out which collision you want to use for your reflection.

If the ball is shallower on the vertical collision than the horizontal collision, you'll want to reflect the vertical, and visa versa. If it's a perfect diagonal hit, you can reflect whichever you want, or both.

If the ball is a circle, it will be a bit trickier. You'll be best off looking for a circle-line collision algorithm rather than me trying to explain it when I don't remember it so clearly.

Sodabread 88 Posting Whiz in Training

If you're just looking for a handout, you came to the wrong place. Try to actually code one and ask us for help where you need it.

Sodabread 88 Posting Whiz in Training

I know this is a little late, but you might also want to look into C# using the XNA framework. I prefer to code in C++, but using XNA really lends itself to getting games up and running rather quickly, plus you have the outlets of Windows, Zune & XBox as your publishing platforms.

Lusiphur commented: Thanks :) Good input +1
Sodabread 88 Posting Whiz in Training

Well, , first off, are you new to programming in general or just game programming?

Sodabread 88 Posting Whiz in Training

Ok. Here's one possible solution. Hopefully this will help a little bit. What you want to do is pass in the int[], as well as an out variable to put in either your run count or the final index of the longest run.

static public int Function(int[] table, out int count)
{
    int counter = 0; // The current count of the run
    int finalCount = 1; // The highest run count
    int lastValue = 0; // The value of the previous array index - can also use [i-1]
    int finalIndex = 0; // The final index of the run
    for (int i = 0; i < table.Length; i++)
    {
        if (table[i] == lastValue) // If the current index matches the last value
        {
            counter++; // Current run increases
            if (finalCount < counter) // Final count should only be changed if less than the current run count
            {
                finalCount = counter;
                finalIndex = i + 1; // Current index is end of current highest run and accounts for base 0 indexing
            }
        }
        else
        {
            counter = 1; // Not a match, so the current run is now 1
        }

        lastValue = table[i]; // Set the lastValue to the current index
    }

    count = finalCount; // Set the out variable to the current count
    return finalIndex; // Return the last index of the highest run
}

With this method, you'll be able to take the final index, subtract the run length (out variable), and get the initial index.

I hope that all makes sense.

Sodabread 88 Posting Whiz in Training

Take a look at adatapost's above code snippet. That statement will sort your selected values from highest to lowest. The table itself may not be ordered that way, but it doesn't need to be when you use the ORDER BY statement.

Sodabread 88 Posting Whiz in Training

As much as I always hate to burst the bubble of an aspiring game developer, J has a good point. How simple are these games you're talking about? Are they just tic-tac-toe and checkers or something similar? For people to buy your games, first you'll need to build something that people want to pay for. If they want to pay for it, but it's not distributed in a really easy way (see: Apple's app store), then you won't get sales because people don't want to go through trouble to download a simple game.

There are distribution channels out there for your games besides Apple's store, but you'll need to build something a lot more impressive than some simple WinForms games (although I would pay for a copy of Castle of the Winds if I could find one to run on Win7). My advice is to get past the simple games and build something bigger & better using C++ & OpenGL/DirectX or C# & XNA or whatever combination of tools you see fit. Using the latter (XNA), you can distribute your games on XBox Live Indie Games, but also through he Zune app store for the more simple ones.

There are a LOT of ways to get your games out there, they just need to be worth buying.

Sodabread 88 Posting Whiz in Training

Have you tried OnSelectedIndexChanged? Don't forget to check Google too when you have questions, as this is one that's got gobs and gobs of information out there.

Sodabread 88 Posting Whiz in Training

As said by a shirt on ThinkGeek, In order to understand recursion, one must understand recursion.

Honestly, I think it's much easier to explain in pseudo code than actual code.

Directory dir = <location>
call renameFilesInDir(dir)

function renameFilesInDir(Directory dir)
    
    foreach(file f in dir)
        rename file

    foreach(directory d in Dir)
        renameFilesInDir(dir)

end

The directory ("C:\" as an example) is created, sending that down into a function. The function does its renames the files, then calls itself for each directory in the root directory. The subsequent call(s) treats the passed in dir (let's use "C:\Windows") as the root, then loops through that entire directory, performing the same exact steps; it renames the files, then calls the function once again for each directory that is in C:\Windows.

In this example, the function will continue to do this until it gets into a folder which has no more folders, so the renameFilesInDir function is not called, the function goes back to the previous call and calls the function again for the next Directory in dir.

Call 1:
dir = C:\

Call 2 (from C:\):
dir = C:\Documents and Settings\

Call 3 (from C:\Documents and Settings\)
dir = C:\Documents and Settings\User 1\

No directories in User 1
Fall back to Call 2

Call 3 (from C:\Documents and Settings\)
dir = C:\Documents and Settings\User 2\

No directories in User 2
Fall back to Call 2

No more directories in Documents …

jonsca commented: Good explanation +4
Sodabread 88 Posting Whiz in Training

And this is exactly what I'm talking about. Shouldn't the terminology be taught early on with stuff like cout, variables and if statements? I would think that it would be a big topic so that students & self-learners can be proficient in talking to others about it and understanding others' material that may not be so reserved in their tech talk.

C++ may not be his native tongue.

Sodabread 88 Posting Whiz in Training

I know this doesn't really fall under computer science, but it's the only forum that this would make sense in.

Is it just me, or does it seem like there are a lot of new programmers that don't understand basic terminology about their language of choice? I don't mean this in any way to be derogatory toward those who are beginners, but I'm curious as to why many of them don't get even the most basic explanation when talking in coding terms.

An example:
I made a replied to a post in the C++ forum and let the OP know that the reason for their error was that the variable they were trying to use (and was coming up with a random number) was uninitialized and/or unassigned. The next reply was "I'm not sure I understand what you mean exactly." Now, that could have been because I didn't delve deeply into the post, just let them know that an uninitialized variable is filled with junk and needs to be initialized or assigned before it can really be used.

Shouldn't this be something that's learned early in tutorials, books & classes? Is there a major deficiency in the way programming is taught? Or do I just happen to run into the certain folks all the time that copy & paste code then try to modify it without having a clue what they're doing?

Sodabread 88 Posting Whiz in Training

http://msdn.microsoft.com/en-us/library/6he9hz8c.aspx

That link should get you to where you could print out the actual form.

As for printing an actual form-like document from an application, there are a couple ways that I can think of to do it, both probably being inefficient as I'm not that good at C# yet.

First, you can design the form in another application like Publisher or InfoPath. Print that out and use that as your paper for printing out form data from your actual form application. It may take you a while to nail down your positioning, but it would work. I know medical offices have applications that do something like this as HCFA forms are done this way many times.

Second, you could spend some time designing the form using the printing framework.

void PrintDoc_PrintPage(object sender, PrintPageEventArgs e)
{
    e.Graphics.DrawLine(new Pen(Color.Aqua, 2.0), new Point(5, 3), new Point(10, 6));
    e.Graphics.DrawRectangle(new Pen(Color.Azure), 250, 65, 20, 15);
    e.Graphics.DrawString(textBox.Text, new Font("Times New Roman", 12), Brushes.Bisque, 250, 65);
    ...
}
jonsca commented: Good advice +4
Sodabread 88 Posting Whiz in Training

One suggestion would be to just keep the initial click position in a variable at the moment of click, as well as the current held position each frame, draw a rectangle using those points. So instead of doing a while loop, you already know where the initial click was, and your after click continues to update every frame instead of waiting for the mouse to be released.

The way I do my input is by using 3 states: up, clicked/pressed and down. The up state is when the mouse button isn't pressed at all. The clicked state should only be active for a single frame, and that's the first frame of which the mouse button is down. The down state is any subsequent frame after the clicked state in which the mouse button is still down. You can just use a series of if statements in your mouse polling function to determine what effects should take place during states, as well as switching from one state to another.

When you do the input this way, it gives you the ability to handle any mouse click or key press in the same fashion.

Sodabread 88 Posting Whiz in Training

You can try using a do...while loop and do b = rand() % 10 + 1 while b equals a.

Sodabread 88 Posting Whiz in Training

See your reportResults function. You're declaring both of these variables in that function, but are never initializing them or assigning any values to them. You then try pass them into assignGrade, but they're filled with garbage and C++ doesn't like garbage filled variables.

Sodabread 88 Posting Whiz in Training

www.sourceforge.net. Take your pick.

Salem commented: Now that's what I call a target rich environment :) +20
Sodabread 88 Posting Whiz in Training

Sodabread's sig is pretty good (and concise enough for t-shirts)

It's a great idea for a t-shirt, actually, considering I stole it off a shirt from ThinkGeek.com =)

Nick Evan commented: :) +0
Sodabread 88 Posting Whiz in Training

End thread hijacking NOW!

No, I will not do your homework.

if(DateTime.Now.Year - Thread.Date.Year > 1)
{
    throw new OldPostException();
}
jephthah commented: "no i will not do your homework!" ahah. that's funny. but, you know, [i]we do[/i].... +0
Sodabread 88 Posting Whiz in Training

What about "

...

"?

Salem commented: Nice! +0
Pro2000 commented: Pretty nice :-) +0
JoshuaBurleson commented: love it, I want one +0
Sodabread 88 Posting Whiz in Training

Has it occurred to you that your plzzzzzzzzzes make it so people want to help you less?

Also, try reading this announcement before posting next time.

ddanbe commented: Well said. +6
jonsca commented: Read my mind actually +4
Ezzaral commented: My thoughts exactly. +10
Sodabread 88 Posting Whiz in Training

It seems that what most people on the outside don't realize about education is that the teacher isn't the single point of success or failure. The kids have to want to learn, and the PARENTS need to be just as involved as the teacher and student. From a younger age, kids need to be shown what a good education can do, instead of just being told they have to go to school and there are no ifs, ands or buts about it. I can't tell you how many times I've heard of parents blaming teachers for their child getting bad grades, not doing their homework and not making up missed tests/work. Parents can make a huge difference in their child's education, but many seem like they're too busy with work and their own life to worry about their kids' futures.

I know there are some teachers out there that work only for a paycheck as there are people in any profession, but the majority of teachers, both that I've had and I've met, care about the kids. If they didn't, they wouldn't be teaching but instead making more money in business. My wife has 2 degrees, one in math and one in physics. She could be making huge amounts of money if she worked as a mathematician or a physicist, but she teaches because she loves it and she cares about the kids. Once you start taking away perks and decent salaries and replacing that with punishment and student …

Sodabread 88 Posting Whiz in Training

Change this and let me know if it works as intended:

if (a1 == 'a1')

to this:

if (a1 == "a1")

If you have more than one character, you need double quotes. Double quotes for strings, single quotes for single characters.

Sodabread 88 Posting Whiz in Training

Here's an example for first web apps, then Windows apps.

string str = new string(((Button)sender).ID);
string str = new string(((Button)sender).Name);

Hope that helps.

Omar123 commented: That fixed my problem, thanks +0
Sodabread 88 Posting Whiz in Training

1. Use code tags.

2. What's the error you're getting?

Sodabread 88 Posting Whiz in Training

Try:

TextBox6.Text = dr(0).ToString

I don't know VB, so however the syntax is supposed to be I have no clue, but this is the idea.

Because you're only selecting a single field, the reader only has that field, so it's at index 0 as far as the reader is concerned.

amalashibu commented: ya,ur code works well.The error was solved +0
Sodabread 88 Posting Whiz in Training

Why would having intimate relations with a sheep (a favourite pastime of my fellow compatriots) and letting it "have a reward" be more of a problem than say, transporting the thing for miles in a couped up shed on wheels and then killing it before chucking its remains on the fire on the off-chance that somebody will want to take a bite out of it? The world's mightily messed up.

Let me get this straight. You're saying it's better to have "intimate relations" with a sheep than to eat it? The former is just gross and the latter is the way nature works. It's the food chain, survival of the fittest if you will. To me, the rights issues need to not revolve around trying to make humanity vegetarian, but to have animals treated ethically. It's one thing to use an animal for food, for natural survival, but it's another thing to treat them like garbage the entire time they're alive just to be slaughtered in the end, which is where the rights should be changed, in my opinion. Animals eating animals is part of nature, but a species as intelligent as we are should also be a bit more compassionate about the treatment of the living. I'm not ALF or PETA, but I do think a line needs to be drawn somewhere.

Sodabread 88 Posting Whiz in Training

You really think that Google is doing this for human rights and not as a PR stunt? It'd be the perfect opportunity for them to pull out of China seeing as how they're at about 25-30% of the market behind Baidu at 60ish%, and they're not gaining any ground. They can just pull out and melt the public's hearts by claiming it to be on grounds of human rights, when it's just to increase their margins. Call me cynical, but I have trouble believing that Google is anywhere close to as ethical as they claim to be.

Sodabread 88 Posting Whiz in Training

An interesting and mind-boggling thread. When God created the universe 6,000 years ago He made it look like the universe was 16 billion years old. Yea, right :)

At the risk of sounding fanatical, how do you know? I'm not saying that I agree that the universe is only 6k years old, but from a religious standpoint, God being all-powerful could have made Earth, the universe, physics, science, everything give humanity (and any other intelligent life elsewhere in the universe) the exact answers we've found. Not saying I believe that either, but it's an interesting view of religion explaining science rather than science attempting to disprove religion. Ultimately, I think that both science & religion are two fields of thought that humanity will never completely understand.

Sodabread 88 Posting Whiz in Training

I just read an article on The Register about Google Chrome OS introducing a new ActiveX style plug-in (Native Client) that allows the browser based OS to run native code and it just got me thinking. Am I alone in thinking that running *everything* on a browser isn't such a good idea? It seems like all these web 2.0 people are going nuts about cloud this and web application that, but I'm a bit hesitant to buy into all the hype.

From an ease of use standpoint, I can see the benefits of running business apps via the web, but from a security standpoint, doesn't it just add another layer of vulnerability with having the browser as an application with holes and the actual LOB application having different holes? I know the developer should be security minded, but there's no such thing as a 100% secure application. Plus, being a hobbyist game developer, I'm afraid WebGL won't compare to DirectX/OpenGL in terms of performance and graphics capabilities. I could be wrong, though.

Do I actually have a basis for my hesitance, or am I just trying to hold on to client apps with too hard a grip?

Sodabread 88 Posting Whiz in Training

The way I see your problem, it can be read in two ways. First, either you're not sure how to work with returned variables, or you're misunderstanding what return actually does.

1st understanding:

You need to catch the return from exitFailure and do something with it.

inFile.open(inputFilename, ios::in);
if (!inFile) 
{
	cerr << "Can't open input file " << inputFilename << endl;
	return exitFailure();
}

or

inFile.open(inputFilename, ios::in);
if (!inFile) 
{
	cerr << "Can't open input file " << inputFilename << endl;
	int retCode = exitFailure();
	return retCode;
}

2nd understanding:
Using return only exits the application if you're returning it from main(). If you use return in another function, it's going to return to the function that called the second.

int exitApp()
{
    return 1; // Returns 1 back to main
}

int main()
{
    exitApp(); // Call exitApp function
    
    return 0; // Exits the application and returns 0 to the OS's application layer (don't quote me on that)
}
Ancient Dragon commented: Nice explanation :) +25
Sodabread 88 Posting Whiz in Training

Why not just have all items inherit from an 'Item' base class and make a vector of Items? I.E., a helmet is a piece of armor, which is a piece of equipment, which is an item. A healing potion is a potion, which is an item. A +3 vorpal short sword is a sword, which is a weapon, which is equipment, which is an item.

Nick Evan commented: That a step in the right direction +11
Sodabread 88 Posting Whiz in Training
Sodabread 88 Posting Whiz in Training

Greetings, everyone. My name's Travis and I'm primarily a game developer focusing on C++, with a little experience in C#, Java, ASP, .NET, PowerShell, and a few other languages that I don't particularly ever want to use again. I joined up here at DaniWeb to use some of my knowledge to try and help others, and to learn a bit more myself, plus I just want to talk code sometimes ;)

I'm looking forward to some good discussions here. See you all on the boards.