Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 401 402 [403] 404 405 ... 796

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

Kirbypowered

  • Bay Watcher
  • Proficient Dabbler
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6030 on: July 01, 2014, 03:13:35 pm »

Well, probably going to throw a little @ in there somewhere, have the program keep track of its coordinates based on key presses, and update the screen each time the coordinates change. I think I can actually do that. =o
Logged
THE WINTER MEN COME DOWN THE VALLEY AND KILL KILL KILL.
I'm voting for the Plaid Acre up next on COLORS AND MEASUREMENTS weekly.

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6031 on: July 01, 2014, 03:33:16 pm »

Spoiler (click to show/hide)
o.O
Logged

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: if self.isCoder(): post() #Programming Thread
« Reply #6032 on: July 01, 2014, 03:41:40 pm »

You might want to consider using an IDE. I've used Code::Blocks for C++, and I liked it just fine.
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

Kirbypowered

  • Bay Watcher
  • Proficient Dabbler
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6033 on: July 01, 2014, 03:49:24 pm »

Spoiler (click to show/hide)
o.O
It appears as though you are watching over my work from the sidelines, guiding me.

You're not there any more though since I fixed that nonsense.

You might want to consider using an IDE. I've used Code::Blocks for C++, and I liked it just fine.
I might just do that once I really get somewhere. I'm still at the level of not knowing exactly what an IDE offers me, besides not having to remember cryptic command line arguments. Which is quite nice.
Logged
THE WINTER MEN COME DOWN THE VALLEY AND KILL KILL KILL.
I'm voting for the Plaid Acre up next on COLORS AND MEASUREMENTS weekly.

frostshotgg

  • Bay Watcher
  • It was a ruse
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6034 on: July 01, 2014, 04:03:08 pm »

An ide tells you what you did wrong, basically.
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #6035 on: July 01, 2014, 04:15:13 pm »

A good IDE will give you good autocomplete without having to tap into the magical aether of existence and draw upon the font of raw knowledge that burns itself into the fabric of your existence and draws away all that is good and holy so you can install an autocomplete tool into emacs or vim.

Autocomplete then lets you not need to remember every function, class or variable name, meaning you can write more classes and functions quicker so can write more smaller classes and functions, and can have longer function/class/variable names so can have cleaner and more descriptive code.

That is useful. Personally I use either Codelite or the Jetbrains C++ IDE, Codelite can use clang to provide autocomplete so can handle all sorts of template voodoo that causes Code::Blocks to fall down in my experience (it can autocomplete boost!). The Jetbrains C++ IDE is still in EAP and invite only so not good for a learner yet.

As for how to write it, well...when you're new typically you throw code at the wall and see what sticks. That's really all there is too it. You'll be able to make something, and whilst I could tell you all about design patterns and testability, you really need to feel the pleasure and pain of the "wall stick" approach before those things will make much sense.
« Last Edit: July 01, 2014, 04:28:41 pm by MorleyDev »
Logged

Kirbypowered

  • Bay Watcher
  • Proficient Dabbler
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6036 on: July 01, 2014, 06:26:12 pm »

Operation move @ man around the screen is mostly successful. Just need to stop him from disappearing whenever he hits a wall...

I was wondering, though I'm probably going to go look it up myself in a moment, how can I change the ways in which the command prompt behaves? Things like having it recognize keyboard input without having to press enter, not having user input show up on the screen, locking the screen size, making the screen not scroll when it refreshes therefore not killing my vision. The sort of stuff common in ASCII roguelikes
Logged
THE WINTER MEN COME DOWN THE VALLEY AND KILL KILL KILL.
I'm voting for the Plaid Acre up next on COLORS AND MEASUREMENTS weekly.

flame99

  • Bay Watcher
  • Lady Stardust & her songs of darkness and disgrace
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6037 on: July 01, 2014, 07:51:33 pm »

I'm having some trouble with a probability calculator made for Warhammer Fantasy Battles in Python. The code probably isn't the most eloquent, but here it is, with the relevant part bolded:
Code: [Select]
x = 1
while x == 1:
Attacks = raw_input ("How many attacks is the attacker making? ")
Attacks = int(Attacks)
AWS = raw_input("What's the attacker's weapon skill? ")
DWS = raw_input("What's the defender's weapon skill? ")
AWS = int(AWS)
DWS = int(DWS)
AWS2 = AWS * 2
if DWS >= AWS:
if DWS <= AWS2:
HitChance = 0.50
elif DWS > AWS2:
HitChance = 0.33
elif DWS < AWS:
HitChance = 0.66
MeanAttacksHit = Attacks * HitChance
HitChance = str(HitChance)
MeanAttacksHit = str(MeanAttacksHit)
print "Chance to hit (In decimal):" + HitChance
print "Average attacks hit: " + MeanAttacksHit
AS = raw_input ("What's the attacker's strength? ")
DT = raw_input ("What's the defender's toughness? ")
AS = int (AS)
DT = int (DT)
AS1 = AS + 1
AS2 = AS - 1
if AS == DT:
WoundChance = 0.50
elif AS1 == DT:
WoundChance = 0.33
elif AS1 < DT:
WoundChance = 0.17
elif AS2 == DT:
WoundChance = 0.66
elif AS2 > DT:
WoundChance = 0.83
MeanAttacksHit = float(MeanAttacksHit)
MeanWounds = MeanAttacksHit * WoundChance
WoundChance = str(WoundChance)
MeanWounds = str(MeanWounds)
print "Chance to hit(In decimal):" + WoundChance
print "Average wounds: " + MeanWounds
BaseSave = raw_input("What is the defender's base armour save? Input 0 for none. ")
BaseSave = int(BaseSave)
ArmourPenalty = AS - 3
if ArmourPenalty < 0:
ArmourPenalty = 0
TotalArmour = BaseSave + ArmourPenalty
if TotalArmour < 0:
TotalArmour = 0
if TotalArmour > 6:
TotalArmour = 0
if TotalArmour == 0:
UnsavedChance = 1
if TotalArmour == 1:
UnsavedChance = 0.17
if TotalArmour == 2:
UnsavedChance = 0.17
if TotalArmour == 3:
UnsavedChance = 0.33
if TotalArmour == 4:
UnsavedChance = 0.50
if TotalArmour == 5:
UnsavedChance = 0.66
if TotalArmour == 6:
UnsavedChance = 0.83
[b]UnsavedChance = float(UnsavedChance)
MeanWoundss = float(MeanWounds)
MeanUnsavedWounds = MeanWounds * UnsavedChance
UnsavedChance = str(UnsavedChance)
print "Chance for the attack to bypass armour (In decimal): " + UnsavedChance
print "Average number of attacks that bypass armour: " + MeanUnsavedWounds
[/b] WardSave = raw_input("What is the defender's ward save? Input 0 for none. ")
if WardSave == 0:
UnwardedChance = 1
if WardSave == 1:
UnwardedChance = 0.17
if WardSave == 2:
UnwardedChance = 0.17
if WardSave == 3:
UnwardedChance = 0.33
if WardSave == 4:
UnwardedChance = 0.50
if WardSave == 5:
UnwardedChance = 0.66
if WardSave == 6:
UnwardedChance = 0.83
MeanUnwardedWounds = MeanUnsavedWounds * UnwardedChance
print "Chance for the attack to bypass armour (In decimal): " + UnwardedChance
print "Average number of attacks that bypass armour: " + MeanUnwardedWounds
raw_input("Thank you for using the Warhammer Fantasy Battles Calculator! ")
x = 0
It all works fine until it tries to calculate the armour, at which point it gives the error:
   MeanUnsavedWounds = MeanWounds * UnsavedChance
TypeError: can't multiply sequence by non-int type of 'float'

UnsavedChance goes to 0 when made into an int, so that's out of the question, and MeanWounds causes another error if I try to convert it to a float. Any ideas on how to get it to stop giving the error?
« Last Edit: July 01, 2014, 08:30:14 pm by flameboy99 »
Logged
It/its, they/them, in order of preference.

Not gay as in happy, queer as in fuck you.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #6038 on: July 01, 2014, 08:16:54 pm »

 MeanWoundss = float(MeanWounds)
   MeanUnsavedWounds = MeanWounds * UnsavedChance

It looks like you made a typo.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6039 on: July 01, 2014, 08:17:17 pm »

Please for the love of Bjarne Stroustrop wrap that with code tags instead of spoiler tags.

flame99

  • Bay Watcher
  • Lady Stardust & her songs of darkness and disgrace
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6040 on: July 01, 2014, 08:29:30 pm »

MeanWoundss = float(MeanWounds)
   MeanUnsavedWounds = MeanWounds * UnsavedChance

It looks like you made a typo.
...

*Begins bashing head into keyboard*

Please for the love of Bjarne Stroustrop wrap that with code tags instead of spoiler tags.
Eheheh...Sorry. I never seem to remember that pretty much every forum has code tags.
Logged
It/its, they/them, in order of preference.

Not gay as in happy, queer as in fuck you.

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6041 on: July 01, 2014, 09:01:43 pm »

Operation move @ man around the screen is mostly successful. Just need to stop him from disappearing whenever he hits a wall...

I was wondering, though I'm probably going to go look it up myself in a moment, how can I change the ways in which the command prompt behaves? Things like having it recognize keyboard input without having to press enter, not having user input show up on the screen, locking the screen size, making the screen not scroll when it refreshes therefore not killing my vision. The sort of stuff common in ASCII roguelikes

What platform?  There's a library or two for most platforms that help with most of that.  For Linux I think the archetypical example is the curses library.
Logged
Through pain, I find wisdom.

Kirbypowered

  • Bay Watcher
  • Proficient Dabbler
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6042 on: July 01, 2014, 09:49:05 pm »

What platform?  There's a library or two for most platforms that help with most of that.  For Linux I think the archetypical example is the curses library.
Windows. I don't know a whole lot about these library things (can I reserve books from them?), but I'd heard good things about libtcod. I started trying to use it once and realized I didn't know what I was doing.
Logged
THE WINTER MEN COME DOWN THE VALLEY AND KILL KILL KILL.
I'm voting for the Plaid Acre up next on COLORS AND MEASUREMENTS weekly.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6043 on: July 01, 2014, 10:05:34 pm »

C++ libraries are frigging intense. I ended up going with Python when I wanted to try libtcod.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #6044 on: July 01, 2014, 11:01:23 pm »

I tried porting my simple game loop engine to Pytho, but python's libtcod version doesn't give you access to SDL events. Honestly, libtcod's kinda sucks >___>
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward
Pages: 1 ... 401 402 [403] 404 405 ... 796