Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 539 540 [541] 542 543 ... 796

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

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8100 on: October 07, 2015, 09:51:59 am »

I managed to fix the issue by reverse engineering some demos in the end, and tweaking them until they did what I want. It turns out the issue was in trying to encapsulate the physics inside my own sprite class, the scope of the various bits and bobs wasn't being maintained properly, because I just copied the code into the constructor of my class. I had assumed it was an encapsulated system and you just need a "body" object and that's that. But nah, you need to permanently store all the sub shit. It's a messy as hell system and not at all encapsulated, I don't really like the design at all.
« Last Edit: October 07, 2015, 09:56:13 am by Reelya »
Logged

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8101 on: October 07, 2015, 11:42:52 am »

What?  I don't think instance variables go in the constructor...
I know Java doesn't do instance variables like that.
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8102 on: October 07, 2015, 02:22:34 pm »

Use emacs and autoconfig on the Linux of your choice.
Logged
Taste my Paci-Fist

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8103 on: October 07, 2015, 02:35:02 pm »

Yeah, most IDEs seem to be more of a roadblock than helpful.
You'll have to read some stuff about autoconfig, though.
Logged
Taste my Paci-Fist

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8104 on: October 07, 2015, 02:47:23 pm »

Well, Debian is pretty configurable on installation, but I guess, if you install a graphical interface, that still has some superfluous stuff.
LFS would be the extreme choice – you only install what you need, but that would take a lot of time.

If you have Windows, there was a nice gui for qemu somewhere. It was really easy to use, very intuitive and stuff.
Logged
Taste my Paci-Fist

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8105 on: October 07, 2015, 03:02:43 pm »

...


Install gentoo?
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8106 on: October 07, 2015, 03:39:24 pm »

What?  I don't think instance variables go in the constructor...
I know Java doesn't do instance variables like that.

No, there were some initializer structs that you set the data in then feed to the main Body object. I naively assumed that once you did that you set the Body object permanently then didn't need the initializer structs anymore. But it breaks if the initializer structs go out of scope after they're used and this wasn't well documented.

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8107 on: October 07, 2015, 03:49:10 pm »

What?  I don't think instance variables go in the constructor...
I know Java doesn't do instance variables like that.

No, there were some initializer structs that you set the data in then feed to the main Body object. I naively assumed that once you did that you set the Body object permanently then didn't need the initializer structs anymore. But it breaks if the initializer structs go out of scope after they're used and this wasn't well documented.
Ah.  I have absolutely no idea what you're talking about.
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

3man75

  • Bay Watcher
  • I will fire this rocket
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8108 on: October 07, 2015, 06:23:53 pm »

Hey guys I need help in determning a way to fix the following code:

Spoiler: Code (click to show/hide)

The code is for a long-distance charing program that tells you how much to pay when you call someone at some point. You firstly charge by WHEN they call which I get with starting time and how LONG the call was with minutes.


My problem comes in at that if I input 19.-33 it skips my error check at line 51 or else if (miniuteremainder <code>).

I've been told that one way to fix is to nest my If's but I wanted to know why this dosen't work and if it can be tweaked so it can work properly. Also If I start nesting them where should I start nesting them?



Example: call during our morning rates and the call lasted 10 minutes.

morningRate*minutes

mornningrate = X
minutes = 10
Logged

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8109 on: October 07, 2015, 06:33:49 pm »

...Can you take TWO arguments (hours/minutes)?  IE:
Code: [Select]
if(minutes > 59 || minutes < 0)
//throw error OR convert hours to minutes and try again.
if (hours > 24 || hours < 0)
//error, but having the capability to handle days, as unlikely as it
//is to occur in real life, might be a feature to add.
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8110 on: October 07, 2015, 06:41:50 pm »

If you input 19.-33 into the C++ console input then you get 19 as a result (because C++ stops reading when it encounters an invalid character)
Logged

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8111 on: October 07, 2015, 06:43:43 pm »

So, I've remembered why I haven't ever actually learned openGL or did any major coding project- Codeblocks does not like libraries. At all. I've spent days (literal days) trying to make libraries work with it, and got nowhere. So, I'm ditching it for whatever else you can recommend here for developing code for c++. IDE, text editor, some distro of Linux- I'll take any suggestions at this point.
Personally I'm a huge fan of CLion, though you basically need to be a student or something similar if you want to get it for free (right side of the "buy and renew" page).
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

3man75

  • Bay Watcher
  • I will fire this rocket
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8112 on: October 07, 2015, 06:56:25 pm »

...Can you take TWO arguments (hours/minutes)?  IE:
Code: [Select]
if(minutes > 59 || minutes < 0)
//throw error OR convert hours to minutes and try again.
if (hours > 24 || hours < 0)
//error, but having the capability to handle days, as unlikely as it
//is to occur in real life, might be a feature to add.

Prof isn't asking for that stuff yet. but I'm a bit loss on the rest. Are you saying to make a varriable cap for 60 min's and then using that at the conditions?
Logged

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8113 on: October 07, 2015, 06:59:26 pm »

I'm saying get two variables, hours and minutes, and store/check them separately.  So, if I understand you correctly, yes.
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

3man75

  • Bay Watcher
  • I will fire this rocket
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8114 on: October 07, 2015, 07:29:54 pm »

I'm saying get two variables, hours and minutes, and store/check them separately.  So, if I understand you correctly, yes.

But why would you make two IF's? If one of the ifs for error are triggered then why check the rest?

Doing If (Hours <24) and if (minutes <.59) would make two seprate checks and that could continue the program despite its answer being flawed.

Also I think I should drop in the complete code to show my gripe. I think it'll be more clear.

Spoiler (click to show/hide)

If you input this and type 19.-33 you'll see it's caught on the second type of error and not the first where it should be caught. I want the -33 to be caught at minute remainder and not minutes. I want to know if this can be tweaked to be correct. If so could you please show me? Otherwise is nesting the If's my only hope?
Logged
Pages: 1 ... 539 540 [541] 542 543 ... 796