Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3] 4 5 ... 796

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

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #30 on: January 03, 2012, 03:23:24 pm »

Well, it's complicated.


Mostly, I'm antisocial and I hate doing stuff to make people happy. I had a designer role before, but I just had to talk to other techies technically.

Now I've to be nice to all sort of client's middle manager and explain all sort of complex stuff dumbed down to their liking because they want to be part of the decision process but without being part if the brain using process.
Logged

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #31 on: January 03, 2012, 03:33:52 pm »



I think he means the position feels more like advertising than anything to do with programming.  And on a personal note, I hate the euphemism of "solution" for "program".

I don't use them as euphemism. I use them as defined within 'the mythical man-month'
Logged

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #32 on: January 03, 2012, 03:44:51 pm »

Syn Athena kai cheira kinei

Unfortunately, my very basic understanding of Greek only lets me recognize two of the words there off the top of my head, and one is technically cheating...

Err -- back on topic!

I've done a little bit of work on my own game using C#, but I was naive even in my pessimism that I had the drive to try to see it through to the end. I've continued to work on the engine I used there for a great many projects that I never really release anywhere. It's come along quite a ways, especially since I started using Bass.Net for music. But I have no current projects on the burner for it.

I have a lot of ideas for projects though, so eventually people will see something...
Logged
In the wells of livestock vans with shells and garden sands /
Iron mixed with oxygen as per the laws of chemistry and chance /
A shape was roughly human, it was only roughly human /
Apparition eyes / Apparition eyes / Knock, apparition, knock / Eyes, apparition eyes /

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #33 on: January 03, 2012, 04:26:33 pm »

That's another thing, MorleyDev. Although I also do not like Java, I don't really want this thread to degenerate into constant bashing of it. From now on, if someone is going to bash a language, either also consider the good parts of the language or don't bash it at all. You're fine, but this is a warning for the future. I know how bad flame wars get among programmers.

Fair enough, I was mostly making a joke of my dislike (hence the red text...computers need some kind of standardised demon font xD) ^^ And the "it works" at the end was to mostly placate things so if someone made a bad reply I could shut down any attacks with "look, it's personal opinion and see, here I even said it works". Think ahead I do ^^

I've not done much programming of late, used the christmas break for break and the non-programming coursework. Most recent project was just me playing around in Lua to make something like LÖVE. I've planned on eventually adding support for other scripting languages too, Javascript especially (probably using Google V8) since that means there is the possibility of embedding the games and such created with it into a website :P
« Last Edit: January 03, 2012, 04:59:56 pm by MorleyDev »
Logged

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #34 on: January 03, 2012, 05:00:59 pm »

I'll have to keep an eye on this thread, sounds like fun.

I've done a lot of development with C and C++, to the point that I'm almost worried that I'm hidebound by them.  I'm reluctant to pick up languages that aren't pretty heavily inspired by them.  To that end, I'm also pretty good with PHP and Javascript, since I work with them all the time at my job.  I have passing familiarity with Java and C#, which is pretty funny considering that I wrote a non trivial game in C# with XNA for a CS class once and still don't really consider myself good with it.

Assembly... I like assembly when it's relevant to be working with it (such as the OS bootloader I wrote for fun once), but if I can avoid it, I do.  It's fun to tinker with it until something goes wrong, then the debugging starts... at least in my case the level of complexity of assembly code I can write doesn't preclude debugging altogether.  I used to be reasonably familiar with x86 assembly as a result of writing that bootloader and some kernel stuff, but I've forgotten most of it, along with the MIPS assembly I had to learn for yet another CS class.

Thinking about all of that kind of depresses me.  I only ever write code these days as part of my graduate research or job, never for fun anymore.  I used to try and write computer games as a hobby, but it's just way too dang time consuming to write anything like I wanted and I just gave up on the idea.  DF was actually sort of the thing I've always wanted to write, but Toady beat me to it, hehe.
Logged
Through pain, I find wisdom.

Aqizzar

  • Bay Watcher
  • There is no 'U'.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #35 on: January 03, 2012, 05:08:16 pm »

Spoiler: Console.Damn() (click to show/hide)

That was my output yesterday, after about four hours of work and study.  Today I have this.

Spoiler: Not just colors. (click to show/hide)

Okay, so it looks almost the same.  The difference is, it now exists in a MainScreen class, and is being drawn by separate functions, including a couple internal methods that handle all of the cursor movements and coloration on their own.  It requires some note-taking on my part, but I'm remembering how important it is that you do actually have to tell the computer everything that you want it to do down to the last detail.  It's a little opaque in practice and redundant in implementation, but it'll save me tons of keystrokes over time.

In other words, I know what I'm doing, and after a whopping six hours or so of work, I know how to draw a screen with extensible methods.
Logged
And here is where my beef pops up like a looming awkward boner.
Please amplify your relaxed states.
Quote from: PTTG??
The ancients built these quote pyramids to forever store vast quantities of rage.

DrKillPatient

  • Bay Watcher
  • The yak falls infinitely
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #36 on: January 03, 2012, 05:45:39 pm »

Does anyone here have experience with graphical tile-based stuff in C++? I'd like to make a roguelike which displays tiles similarly to DF; since I suppose that using basic graphics rather than the console/terminal will make it more portable (ideally Mac OSX and GNU/Linux, but Windows would be nice too). Right now I'm looking at using OpenGL's texture mapping on an 80x25 group of squares (each square being the same size as one character in the tileset) which are drawn in a window. Is that a good way to go about it, or is there a better option?
Logged
"Frankly, if you're hanging out with people who tell you to use v.begin() instead of &v[0], you need to rethink your social circle."
    Scott Meyers, Effective STL

I've written bash scripts to make using DF easier under Linux!

kaijyuu

  • Bay Watcher
  • Hrm...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #37 on: January 03, 2012, 05:52:36 pm »

SDL is probably less complicated, but if you've got the basics of OpenGL down, stick to it.
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.

Yannanth

  • Guest
.
« Reply #38 on: January 03, 2012, 05:59:24 pm »

.
« Last Edit: November 22, 2016, 05:16:05 am by Yannanth »
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #39 on: January 03, 2012, 06:13:48 pm »

SFML2 is a bit of a dick to build at the moment since no official prebuilt binaries are out there (it's still a WIP and so the API isn't finalised, but SFML 1.6 has issues with ATI cards after a patch to those drivers), but when built it's pretty simple to use and was essentially designed an OOP successor to SDL.

But if you can use OpenGL, odds are you won't lose anything by implementing your own wrappers around it (may even gain in performance due to being able to specialise and optimise towards specific goals instead of being generic) and it's a learning experience :) Splitting a texture of ASCII characters into subtextures that are rendered as tiles is basically how Dwarf Fortress does it (with some extra stuff for replacing textures for creatures and stuff for the tilesets).
« Last Edit: January 03, 2012, 06:16:11 pm by MorleyDev »
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #40 on: January 03, 2012, 06:46:53 pm »

I know this is something the other programming thread did/does, but I like the idea and I'm going to do it here too.

I issue a challenge to Bay12 programmers.

Challenge: Write a program in any language of your choosing that acts as an interpreter for that language, in that it takes code as input and gives the output from running that code.

Restrictions: If you are using an interpreted language, you cannot simply use a built-in function that takes code as input and gives you the output, like Python's exec() function. You can use anything else, whether it is built-in, code you write, or a third-party library. In addition, simply copying an example from the internet won't teach you anything except how to copy and paste code. This is for people to develop their skills and learn more about different programming languages.

Let's see how many different languages we can get here. In a little bit, if I can find it, I'll post my C++ program.

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #41 on: January 03, 2012, 08:09:30 pm »

SDL is probably less complicated, but if you've got the basics of OpenGL down, stick to it.

Doesn't SDL use OpenGL for it's graphics?

Does anyone here have experience with graphical tile-based stuff in C++? I'd like to make a roguelike which displays tiles similarly to DF; since I suppose that using basic graphics rather than the console/terminal will make it more portable (ideally Mac OSX and GNU/Linux, but Windows would be nice too). Right now I'm looking at using OpenGL's texture mapping on an 80x25 group of squares (each square being the same size as one character in the tileset) which are drawn in a window. Is that a good way to go about it, or is there a better option?

I never read it, but I do remember that Baughn's SDL code was available at one point or other.  Is it still?  Could be a decent reference for you.

Did someone say assembly code?

I've always wanted to do something like that...but I've been utterly terrified to try.

I know this is something the other programming thread did/does, but I like the idea and I'm going to do it here too.

I issue a challenge to Bay12 programmers.

Challenge: Write a program in any language of your choosing that acts as an interpreter for that language, in that it takes code as input and gives the output from running that code.

Restrictions: If you are using an interpreted language, you cannot simply use a built-in function that takes code as input and gives you the output, like Python's exec() function. You can use anything else, whether it is built-in, code you write, or a third-party library. In addition, simply copying an example from the internet won't teach you anything except how to copy and paste code. This is for people to develop their skills and learn more about different programming languages.

Let's see how many different languages we can get here. In a little bit, if I can find it, I'll post my C++ program.

Write an IDE for the language it's written in?  As in, write an environment, compiler, linker, and assembler?  You're insane.  Also, I'm pretty sure this is an assignment in one of my CS classes...
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #42 on: January 03, 2012, 08:30:50 pm »

I am insane, but I didn't say a full-blown IDE. Just an interpreter. Read from stdin, write to stdout. For example:

Code: (eval.cpp) [Select]
#include <string>

#include <sys/types.h>

#include <unistd.h>

#include <fstream>

#include <vector>

#include <iostream>



using namespace std;



ostream& operator<<(ostream& ostr, vector<string> in) {

    ostr << "[\"";

    for(vector<string>::iterator it = in.begin(); it != in.end(); it++) {

        ostr << *it << '"';

        if(it+1 != in.end()) ostr << ",\"";

    }

    ostr << ']' << endl;

    return ostr;

}



vector<string> eval(vector<string> what) {

    ofstream out("temp.cpp", ios_base::trunc);

    vector<string> ret;

    if(!out.is_open()) throw "File creation failure";

    out << "#include \"includes.h\"" << endl;

    out << "int main(int argc, char** argv) {" << endl;

    out << "setup();" << endl;

    for(vector<string>::iterator it = what.begin(); it != what.end(); it++)

        out << *it << endl;

    out << "teardown();" << endl;

    out << "return 0;" << endl;

    out << "}" << endl;

    out.close();

    pid_t f_id = vfork();

    if(f_id < 0) throw "Fork failure";

    else if(f_id == 0) {

        pid_t f_id2 = vfork();

        if(f_id2 < 0) throw "Fork failure";

        else if(f_id2 == 0)

            execlp("g++", "g++", "-o", "temp", "temp.cpp", NULL);

        else

            execlp("./temp", "./temp", NULL);

    }

    else {

        ifstream in("temp.out");

        string line;

        while(getline(in, line)) ret.push_back(line);

    }

    return ret;

}



int main() {

    string input;

    vector<string> vin;

    while(cin.good()) {

        getline(cin, input);

        vin.push_back(input);

    }

    cout << eval(vin) << endl;

    return 0;

}


That, along with the other file, includes.h, will work similarly to an interpreter.

Code: (includes.h) [Select]
#include <algorithm>
#include <complex>
#include <exception>
#include <list>
#include <stack>
#include <bitset>
#include <csetjmp>
#include <fstream>
#include <locale>
#include <stdexcept>
#include <cassert>
#include <csignal>
#include <functional>
#include <map>
#include <cctype>
#include <cstdarg>
#include <iomanip>
#include <memory>
#include <streambuf>
#include <cerrno>
#include <cstddef>
#include <ios>
#include <new>
#include <string>
#include <cfloat>
#include <cstdio>
#include <iosfwd>
#include <numeric>
#include <typeinfo>
#include <ciso646>
#include <cstdlib>
#include <iostream>
#include <utility>
#include <climits>
#include <cstring>
#include <queue>
#include <valarray>
#include <clocale>
#include <ctime>
#include <iterator>
#include <set>
#include <vector>
#include <cmath>
#include <deque>
#include <limits>
#include <sstream>
using namespace std;

streambuf *backup, *outbuf;
ofstream out("temp.out");

void setup() {
    outbuf = out.rdbuf();
    backup = cout.rdbuf(outbuf);
}

void teardown() {
    cout.rdbuf(backup);
    out.close();
}

That long list of #include's is every header file in the C++ Standard Library. Other common third-party libraries such as the POSIX library or Boost were not included for sanity purposes.

EDIT: Indentation formatting was bugging me. I think I program in Python too much.
« Last Edit: January 03, 2012, 08:35:21 pm by Mego »
Logged

kaijyuu

  • Bay Watcher
  • Hrm...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #43 on: January 03, 2012, 08:38:16 pm »

SDL is probably less complicated, but if you've got the basics of OpenGL down, stick to it.

Doesn't SDL use OpenGL for it's graphics?
Maybe? I know there's some cross compatibility, so it wouldn't hugely surprise me. I'm able to render graphics with OpenGL and put them into a window made by SDL with a single standard function call.
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.

MaximumZero

  • Bay Watcher
  • Stare into the abyss.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #44 on: January 03, 2012, 08:52:02 pm »

One day, I'm going to be able to post something useful in these threads...but until then, I'm just posting to watch.
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
Pages: 1 2 [3] 4 5 ... 796