Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 100 101 [102] 103 104 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 883002 times)

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1515 on: February 16, 2012, 08:12:46 pm »

You probably need to re-render with each frame.

Something like:  TCODConsole::root->console_flush()   in your while loop.

(although I'm not sure of the exact syntax)
« Last Edit: February 16, 2012, 08:14:48 pm by Levi »
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

Simmura McCrea

  • Bay Watcher
    • View Profile
    • My Steam profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1516 on: February 16, 2012, 08:16:27 pm »

Same thing, just a blank frozen window.
Logged

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1517 on: February 16, 2012, 08:20:21 pm »

I don't know what a 201 course is, but it's not quite an introductory course. The class has a pre-requisite called Computer Logic, which I assume would cover these things. Problem is, I took that class several years ago, and it was basically making endless flow charts and a little bit of pseudocode. No real code involved in any language. Talking to the other students, it seems like the curriculum changed a great deal while I was gone, and actually does some Assembly or UNIX or something now. It's still supposed to be a basics class, since we started with the classic Hello World and began working our way up.
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

Simmura McCrea

  • Bay Watcher
    • View Profile
    • My Steam profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1518 on: February 16, 2012, 08:40:44 pm »

You probably need to re-render with each frame.

Something like:  TCODConsole::root->console_flush()   in your while loop.

(although I'm not sure of the exact syntax)
That's got it. Cheers.
Logged

MaximumZero

  • Bay Watcher
  • Stare into the abyss.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1519 on: February 16, 2012, 11:09:02 pm »

Why does OOP feel so different than Procedural programming? I'm freaking lost. I don't even know what I'm supposed to be doing.
Logged
  
Holy crap, why did I not start watching One Punch Man earlier? This is the best thing.
probably figured an autobiography wouldn't be interesting

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1520 on: February 16, 2012, 11:15:03 pm »

Why does OOP feel so different than Procedural programming? I'm freaking lost. I don't even know what I'm supposed to be doing.

Just pretend you are doing procedural programming then, but:

- If you have data, put it in an class.
- If you have a function that manipulates that data, put that function in the same class.

Although I suppose depending on what you are working on, that might not always work.  :)
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1521 on: February 17, 2012, 01:58:40 am »

Ok, I've been beating my head against this problem for the past two hours, and this assignment is due by midnight, so if I could kindly have a little help? I think the problem is that it's not calling the calculate function properly, as the program will run, and it'll do the printf() statements just fine, but I just get zeroes and 8-digit numbers.
Spoiler (click to show/hide)
The only error I can see on-screen (and again, the program will actually run with it), is a red line under the outputData statement in the main function. Mousing over it gives the message "no instance of overloaded function "outputData" matches the argument list".
« Last Edit: February 17, 2012, 02:01:51 am by Sirus »
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1522 on: February 17, 2012, 02:10:03 am »

Well, have you tried removing the &* from the getData function? If that doesn't work, you should at least have the program echo the inputted values to check if they got into the program correctly.
« Last Edit: February 17, 2012, 02:15:40 am by RulerOfNothing »
Logged

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1523 on: February 17, 2012, 02:19:39 am »

Same result as before. Damn.
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

Xegeth

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1524 on: February 17, 2012, 02:20:43 am »

You have the wrong function declarations. outputData needs arguments on line 8, and calculate uses pointers in the declaration but not the definition. I'd guess the program runs because it compiled in the past and you're using the old version of the program.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1525 on: February 17, 2012, 02:22:09 am »

Yea, what Xegeth said. For example, first few lines of code should be...


Code: [Select]
#include <stdio.h>

#define TAX_RATE 8.50

//Function Declarations
void getData(int*, float*, float*);
void calculate(float*, int*, float*, float*, float*, float*, float*, float*);
void outputData(int quantity, float unitPrice, float subTotal, float discountAm, float subTaxable, float taxAm, float total)

kaijyuu

  • Bay Watcher
  • Hrm...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1526 on: February 17, 2012, 02:26:26 am »

Wonder if anyone here has any experience with this....


I'm tired of hardcoding behavior of sprites/etc in my game. Compile times get incredibly long when doing it in raw c++, plus making tools for myself would make things much less tedious and repetitive. I need to stop putting attributes in the c++ files themselves, and make me a tool where I can modify and import them into the game, like a real engine.

So I need to implement a scripting language for behavior. Any suggestions? I'm looking into Lua right now and it looks pretty nifty. However I have zero experience with it (or most scripting languages, really) so before I take the dive I'd like some second opinions. Some friends of mine are suggesting Python, as well.

It just needs to be able to interact with c++ and be easily written within a Qt application (which I'll be making my tools with --  has decent text editor functionality IIRC so that shouldn't be an issue). Speed is also a factor, as I'll be using it for everything's behavior, including stuff like particle effects. I'd love to write my own, but I don't want to spend 3 years making this, when I can have a much more versatile language implemented in half the time. Plus I plan to release this game engine someday, and a well known language will make it easier for people to pick up.
Logged
Quote from: Chesterton
For, in order that men should resist injustice, something more is necessary than that they should think injustice unpleasant. They must think injustice absurd; above all, they must think it startling. They must retain the violence of a virgin astonishment. When the pessimist looks at any infamy, it is to him, after all, only a repetition of the infamy of existence. But the optimist sees injustice as something discordant and unexpected, and it stings him into action.

fergus

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1527 on: February 17, 2012, 02:28:05 am »

First, there's some problems with function definitions:

Code: [Select]
void calculate(float*, int*, float*, float*, float*, float*, float*, float*);
void calculate(float subTotal, int quantity, float unitPrice, float discountAm, float discountRate, float subTaxable, float taxAm, float total)
This is probably your problem, I'm pretty sure you want to pass by value, not by reference, so remove the *'s from the first line.

Code: [Select]
void outputData();
void outputData(int quantity, float unitPrice, float subTotal, float discountAm, float subTaxable, float taxAm, float total)
I'm surprised this even compiles without an error, but you need to change the first line to match the second.

As for actually calling them:
Code: [Select]
calculate(&subTotal, &quantity, &unitPrice, &discountAm, &discountRate, &subTaxable, &taxAm, &total);
outputData(&quantity, &unitPrice, &subTotal, &discountAm, &subTaxable, &taxAm, &total);
Both of these are wrong: outputData doesn't need pointers and calculate does need them, but doesn't dereference them properly, it does direct arithmetic on the values passed, not on the values pointed to, which explains the large numbers. To do this correctly, you should dereference the pointers in calculate when you use them.

Third, you should remove the &* from getData, printf doesn't generally use pointers and you should pass the values instead.
Logged
BY THE GODS! THIS QUOTE MADE MY SIG BOX HAVE A SCROLL BAR! HAPPY DAYS INDEED!
BY THE GODS! YOU HAVE TOO MANY SIGS!

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1528 on: February 17, 2012, 02:34:51 am »

Ok, I made those changes (though I can't say I remember seeing that in any of my previous assignments, sample programs, or notes, but w/e), and got rid of the ampersands in the outputData statement (they were showing up as an error). This got the program to run, but the results for each of the calculations are -107374176.00. I'm assuming that that's not correct, so back to the drawing board I go.

Fergus, a quick look in my textbook's index shows that "dereference" doesn't show up for another 400 pages. In simple English, please?
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1529 on: February 17, 2012, 02:45:03 am »

*Facepalm*
In programming, when you have an error, and you have several theories on how to solve it, it is best to keep your testing atomic.
That is to say, implement one solution, test it, and if it works you are set! Otherwise, undo the changes and try the next idea... Why would you remove the ampersands and extend the signature of the forward deceleration without testing in between?
Pages: 1 ... 100 101 [102] 103 104 ... 796