Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 394 395 [396] 397 398 ... 796

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

da_nang

  • Bay Watcher
  • Argonian Overlord
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5925 on: May 30, 2014, 04:55:32 pm »

Quote from: PHP
"string" == 0
"string" == TRUE
TRUE != 0
The comparison operator does not have the transitive property.

The comparison operator has no transitive property.
When using it on basic built-in types.

Why hasn't this whole language been nuked from orbit again?

Relevant
Logged
"Deliver yesterday, code today, think tomorrow."
Ceterum censeo Unionem Europaeam esse delendam.
Future supplanter of humanity.

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5926 on: May 30, 2014, 05:34:35 pm »

Quote from: PHP
"string" == 0
"string" == TRUE
TRUE != 0
The comparison operator does not have the transitive property.

The comparison operator has no transitive property.
When using it on basic built-in types.

Why hasn't this whole language been nuked from orbit again?

I seem to recall that "NULL" == NULL is true too.  Type coercion with strings is so convenient sometimes and makes life easy, but boy does it lead to interesting bugs sometimes.
Logged
Through pain, I find wisdom.

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5927 on: May 30, 2014, 07:55:56 pm »

Okay, I feel a bit dumb right now: I'm storing map data as 9 byte blocks written end to end in a file, and I want to retrieve them using their x, y, z coordinates. What is the general formula for getting to the exact file offset I want to read from?
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 /

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: if self.isCoder(): post() #Programming Thread
« Reply #5928 on: May 30, 2014, 08:11:41 pm »

Okay, I feel a bit dumb right now: I'm storing map data as 9 byte blocks written end to end in a file, and I want to retrieve them using their x, y, z coordinates. What is the general formula for getting to the exact file offset I want to read from?
So you're converting from coordinates to an absolute position? In that case you could do something like this:
Code: [Select]
//x y and z are the coordinates
offset = (x + y * width + z * width * height) * 9;  // 9 is the block size
This is assuming your data is stored in row-column-layer order... and also assuming I interpreted your problem right.
Logged
Think of it like Sim City, except with rival mayors that seek to destroy your citizens by arming legions of homeless people and sending them to attack you.
Quote from: Moonshadow101
it would be funny to see babies spontaneously combust
Gat HQ (Sigtext)
++U+U++ // ,.,.@UUUUUUUU

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5929 on: May 30, 2014, 08:22:45 pm »

Okay, I feel a bit dumb right now: I'm storing map data as 9 byte blocks written end to end in a file, and I want to retrieve them using their x, y, z coordinates. What is the general formula for getting to the exact file offset I want to read from?
So you're converting from coordinates to an absolute position? In that case you could do something like this:
Code: [Select]
//x y and z are the coordinates
offset = (x + y * width + z * width * height) * 9;  // 9 is the block size
This is assuming your data is stored in row-column-layer order... and also assuming I interpreted your problem right.
Not exactly, but you managed to describe it in such a way that I was able to adapt it to my data set and now it works. \o/

Thank you so much!

*"not exactly" in reference to how it's stored, you did understand the problem correctly.
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 /

Verdant_Squire

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5930 on: June 02, 2014, 10:12:09 pm »

I've been wanting to try out a roguelike project to test out my newly obtained understanding of coding. Does anyone here have any recommendations for object-based coding languages, and tools for using them? And on top of that, advice for building turn-based games in general?
Logged

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5931 on: June 02, 2014, 10:22:31 pm »

C++ is still pretty much the industry standard for most large games, and is what DF is written in.  Having said that, it takes a lot of work to go from an empty project to even displaying stuff on the screen so I wouldn't recommend it if you're not familiar with it already.

I'm not familiar with using scripting languages for this sort of thing really, but if you want to try a more modern language you might want to take a look at Python.  It has a lot of libraries for most things you'd need, I believe.

If you want something closer to the typical curly brace languages, C# and XNA might not be a bad option.  I built a 2D game with XNA for a university class once, and it's pretty capable.  It's a lot less work than starting from nothing with C++ for sure.

General advice I'm afraid is a bit hard to provide.  Game development is a gigantic field.  :)  One thing I would suggest is trying to start with a framework or prebuilt engine, because a lot of people very reasonably suggest that since you're interested in making a game and not an engine, there's no reason to waste time doing that and lose enthusiasm.  XNA has a lot of prebuilt stuff to help with that, but I wouldn't consider it much more than a low level framework.  I'm not familiar with any 2D engines for any language though, so maybe someone else can provide that.
Logged
Through pain, I find wisdom.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5932 on: June 02, 2014, 11:51:42 pm »

There's a cool challenge, the 1kb roguelike. In that, you make a roguelike but your source code must be no greater than 1024 characters. It's a good learning challenge for efficient coding, and you'd be amazed how much stuff you can actually jam in their if you really try.

Arx

  • Bay Watcher
  • Iron within, iron without.
    • View Profile
    • Art!
Re: if self.isCoder(): post() #Programming Thread
« Reply #5933 on: June 03, 2014, 03:24:53 am »

There's a cool challenge, the 1kb roguelike. In that, you make a roguelike but your source code must be no greater than 1024 characters. It's a good learning challenge for efficient coding, and you'd be amazed how much stuff you can actually jam in their if you really try.

That sounds like a lot of fun.

Anyway, I have a problem:

In Netbeans 7.0.1 on Linux Mint 14, if I attempt to create a JavaDB Database (as superuser) I get this error:

Quote
An error occurred while creating the database: java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused..

What have I do wrong? I can't find anything about this, but my Google-fu may just be weak.
Logged

I am on Discord as Arx#2415.
Hail to the mind of man! / Fire in the sky
I've been waiting for you / On this day we die.

da_nang

  • Bay Watcher
  • Argonian Overlord
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5934 on: June 03, 2014, 04:07:13 am »

There's a cool challenge, the 1kb roguelike. In that, you make a roguelike but your source code must be no greater than 1024 characters. It's a good learning challenge for efficient coding, and you'd be amazed how much stuff you can actually jam in their if you really try.
Does that include imported code?
Logged
"Deliver yesterday, code today, think tomorrow."
Ceterum censeo Unionem Europaeam esse delendam.
Future supplanter of humanity.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5935 on: June 03, 2014, 08:31:02 am »

There's a cool challenge, the 1kb roguelike. In that, you make a roguelike but your source code must be no greater than 1024 characters. It's a good learning challenge for efficient coding, and you'd be amazed how much stuff you can actually jam in their if you really try.

That sounds like a lot of fun.

Anyway, I have a problem:

In Netbeans 7.0.1 on Linux Mint 14, if I attempt to create a JavaDB Database (as superuser) I get this error:

Quote
An error occurred while creating the database: java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused..

What have I do wrong? I can't find anything about this, but my Google-fu may just be weak.

Make sure the database service is running and listening on that port.

Arx

  • Bay Watcher
  • Iron within, iron without.
    • View Profile
    • Art!
Re: if self.isCoder(): post() #Programming Thread
« Reply #5936 on: June 03, 2014, 08:42:01 am »

The JavaDB server is definitely running. Could you elaborate on the listening bit? Thanks, though!
Logged

I am on Discord as Arx#2415.
Hail to the mind of man! / Fire in the sky
I've been waiting for you / On this day we die.

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5937 on: June 03, 2014, 09:27:43 am »

The 1kb roguelike doesn't sound like it'd focus on efficiency much, more on relentlessly abusing features of the language you're using to cram in as much code as possible. Still sounds interesting, though :P
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.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5938 on: June 03, 2014, 08:34:49 pm »

The JavaDB server is definitely running. Could you elaborate on the listening bit? Thanks, though!

Well, that error message implies that one of two things is going on. First, it could be that the server isn't listening. In order to communicate with other processes, the server needs to be listening on that port - waiting for connections. There should be a setting somewhere in the configuration that specifies which port it's listening on.

Second, it could be an issue with authentication, if you have any set up, but this is less likely.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5939 on: June 04, 2014, 12:12:48 am »

There's a cool challenge, the 1kb roguelike. In that, you make a roguelike but your source code must be no greater than 1024 characters. It's a good learning challenge for efficient coding, and you'd be amazed how much stuff you can actually jam in their if you really try.
Does that include imported code?
Generally, you're allowed to use standard libraries and the like, but you have to count the #include statements as part of your code. So, custom header files are out but any default-language stuff is usually considered ok. you need to link in libraries like curses.h or iostream.h anyway for console output.
Pages: 1 ... 394 395 [396] 397 398 ... 796