Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 75 76 [77] 78 79 ... 91

Author Topic: Programming Help Thread (For Dummies)  (Read 100451 times)

Urist McScoopbeard

  • Bay Watcher
  • Damnit Scoopz!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1140 on: August 07, 2013, 11:20:45 am »

right so, using java, is-there-a/what-is-the-easiest way to draw irregular shapes and then fill them with color?

entirely 2-dimensional, irregular, non-symmetric shapes.

any advice is welcome, thanks in advance!
Logged
This conversation is getting disturbing fast, disturbingly erotic.

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: Programming Help Thread (For Dummies)
« Reply #1141 on: August 07, 2013, 11:24:48 am »

That depends on which library you're using. I suggest you either look for polygon functionality, or you just use a prepared image.
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

Urist McScoopbeard

  • Bay Watcher
  • Damnit Scoopz!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1142 on: August 07, 2013, 11:31:36 am »

polygon functionality it is, prepared images are exactly what i'm attempting to avoid.

Thanks very much man!
Logged
This conversation is getting disturbing fast, disturbingly erotic.

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1143 on: August 07, 2013, 01:10:16 pm »

While the syntax is quite similar, the horrors of compiler errors and templates and types is quite a thing.

Compare
std::mao<std::string, int> dictionary;
and, for Perl (I don't knke the syntax for dictionaries in Python off the top of my head)
$dictionary {"one"->1};

Also, to beginners most compiler errors look like CERROR 39482 SOMETHING BROKE AND YOU CAN'T FIX IT. C++ errors are among the less helpful ones, though it does improve for modern compilers.
Just want to point out how we're discussing "What's it like to use Python" and you pull up C++ and Perl.  This appears to be fantastically irrelevant.
You were the one that said "you can easily find C++ tutorials" when I asked for Python tutorials, tough :P

E: I found the tutorial that I lost, tough, with some more creative google searches.

Just found this: http://www.raywenderlich.com/24252/beginning-game-programming-for-teens-with-python
Written by someone BORN AFTER THE YEAR 2000. Now I feel old and accomplishmentless.

Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

socks

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1144 on: August 08, 2013, 01:46:14 pm »

super noob question time! In c++, how do I use the '\' character in a string without it disappearing or doing something else?
« Last Edit: August 08, 2013, 02:03:58 pm by socks »
Logged

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1145 on: August 08, 2013, 02:30:39 pm »

super noob question time! In c++, how do I use the '\' character in a string without it disappearing or doing something else?

\\

Escape your slash with a slash.  :)
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

socks

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1146 on: August 08, 2013, 02:37:38 pm »

thank you  :D
Logged

NobodyPro

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1147 on: August 10, 2013, 04:57:07 am »

So I'm writing something for FG&RP using Python 2.7 and I've hit a problem. The following code works as planned:
Code: [Select]
    for item in activeFighters:
        if FighterSelected >= len(activeFighters):
            FighterSelected = 0
        else: FighterSelected += 1
    #   Determine target (create threat evaluation system)
        potentialTarget = len(activeFighters)-1
        while activeFighters[FighterSelected].team == activeFighters[potentialTarget].team:
            potentialTarget -= 1
but if I stick this in a while loop like this:
Code: [Select]
    while len(activeFighters) != 1:
    #   Change fighter being controlled
        for item in activeFighters:
            if FighterSelected >= len(activeFighters):
                FighterSelected = 0
            else: FighterSelected += 1
        #   Determine target (create threat evaluation system)
            potentialTarget = len(activeFighters)-1
            while activeFighters[FighterSelected].team == activeFighters[potentialTarget].team:
                potentialTarget -= 1
I get an error:
Code: [Select]
Traceback (most recent call last):
  File "G:\WIP\Gladiator Script\main.py", line 410, in <module>
    main()
  File "G:\WIP\Gladiator Script\main.py", line 403, in main
    while activeFighters[FighterSelected].team == activeFighters[potentialTarget].team:
IndexError: list index out of range
Which makes no sense as the list indexes were fine prior to the loop and the loop doesn't finish, I tested for that. I would really appreciate some help.
Logged

Anvilfolk

  • Bay Watcher
  • Love! <3
    • View Profile
    • Portuguese blacksmithing forum!
Re: Programming Help Thread (For Dummies)
« Reply #1148 on: August 10, 2013, 05:03:34 am »

I'd suggest debugging it through eclipse, or printing all of the indices at relevant points so that you can figure out what's happening. There's really only two possibilities: either you're using a negative index (like -1) or you're going over the size of the array.

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1149 on: August 10, 2013, 09:45:21 am »

Try adding:

FighterSelected = 0

on the second line between the while and for loop.  The only thing I can think of is FighterSelected is somehow getting set to a value below 0 after your for-loop somewhere, which would cause that error on that line.
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

Mephisto

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1150 on: August 10, 2013, 10:13:42 am »

Code: [Select]
    while len(activeFighters) != 1:
    #   Change fighter being controlled
        for item in activeFighters:
            if FighterSelected >= len(activeFighters):
                FighterSelected = 0
            else: FighterSelected += 1
        #   Determine target (create threat evaluation system)
            potentialTarget = len(activeFighters)-1
            while activeFighters[FighterSelected].team == activeFighters[potentialTarget].team:
                potentialTarget -= 1

Are all fighters on the same team? If that's the case, potentialTarget could go negative.
Logged

NobodyPro

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1151 on: August 10, 2013, 08:45:34 pm »

Problem solved. 'if FighterSelected >= len(activeFighters)' was checking for two, and I'd forgotten to stick a -1 on the end of that to account for the fact that lists start at position 0.
Logged

NobodyPro

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1152 on: August 12, 2013, 02:04:11 am »

EDIT: I went and fiddled with the formatting in the txt files I was pulling data from and my other problem fixed itself. The problem I had had NOTHING to do with those txt files.
« Last Edit: August 12, 2013, 04:57:10 am by NobodyPro »
Logged

HopFlash

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1153 on: August 17, 2013, 05:43:39 pm »

How would you suggest I handle pathfinding?  In particular, the code is Python and simple pathfinding is good enough.  Ideally I'd like something similar to DF, with priorities of 'don't pass through here if you can avoid it' and whatnot.

In a bit more specifics, the idea is to have, more or less, 'DF on a spaceship' and deal with issues like spacing and whatnot, so ideally it'd run a test 'pathfind to this location safely' and then 'pathfind here and use a space suit'.

EDIT:
http://www.policyalmanac.org/games/aStarTutorial.htm
This is the best thing.
perhaps an interesting visualisation for pathfinding:
http://qiao.github.io/PathFinding.js/visual/

"Jump Point" seems as an interesting alternative but I for myself havn't tried it.
Logged
GENERATION 11: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.

Inactive Therian Saga Char: Stormhead
Dominions: 4.03 Berytos; 4.06 Pangaea; 4.08 Arcoscephale; 4.11 Shinuyama
Inactive Wurm Online Char: Stormhead

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #1154 on: August 18, 2013, 04:52:41 am »

What's the difference between Python 2.7 and 3.3?
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.
Pages: 1 ... 75 76 [77] 78 79 ... 91