Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 69 70 [71] 72

Author Topic: The Roguelike Development Megathread  (Read 239957 times)

McDonald

  • Bay Watcher
  • Passwords get hidden, who knew? ••••••••
    • View Profile
Re: The Roguelike Development Megathread
« Reply #1050 on: December 15, 2014, 02:47:20 pm »

I'm creating a roguelike right now in C++. I just finished opening doors.

Then I started laughing (and still am) because I remember playing NetHack once. I walked around kicking everything. WHAAM!! WHAAM!!  Ouch, that hurt!
Logged
I'm with stupid |
                      v

Lightningfalcon

  • Bay Watcher
  • Target locked. Firing main cannon.
    • View Profile
Re: The Roguelike Development Megathread
« Reply #1051 on: December 18, 2014, 06:56:42 pm »

So it has been a few months since I've last done any serious programming, and thought learning to make a rougelike would be a good way to get my feet wet for the programming course I'm taking next semester.  I'm following this tutorial right here- http://www.roguebasin.com/index.php?title=Java_Roguelike_Tutorial_Lesson_One
I'm using Eclipse, but I've ran into a problem.  Eclipse keeps saying that this line of code
Code: [Select]
csi = new WSwingConsoleInterface("Thing", text);is not correct, and keeps suggesting that I turn text into a boolean. 

And while I'm posting here, does anyone else know any good tutorials for java?
Logged
Interdum feror cupidine partium magnarum circo vincendarum
W-we just... wanted our...
Actually most of the people here explicitly wanted chaos and tragedy. So. Uh.

rmblr

  • Bay Watcher
    • View Profile
Re: The Roguelike Development Megathread
« Reply #1052 on: December 19, 2014, 02:49:53 am »

That's because it should be a boolean (true or false), not a string variable.

Checkout the documentation for that class constructor: http://slashie.net/libjcsi/doc/net/slashie/libjcsi/wswing/WSwingConsoleInterface.html#WSwingConsoleInterface(java.lang.String, boolean)

Code: [Select]
public WSwingConsoleInterface(java.lang.String windowName, boolean sandboxDeploy)

Allows for setting the window's name and deploying as a Java WebStart application.

Parameters:
windowName -
sandboxDeploy - true if intended at a Java Webstart application

Since you probably aren't deploying in a sandbox, just set it to false.
Logged

Lightningfalcon

  • Bay Watcher
  • Target locked. Firing main cannon.
    • View Profile
Re: The Roguelike Development Megathread
« Reply #1053 on: December 19, 2014, 03:13:03 am »

Huh.  The tutorial goes on about how it is a properties that should go there.  I'll just have to figure out a way around that tomorrow morning.
Logged
Interdum feror cupidine partium magnarum circo vincendarum
W-we just... wanted our...
Actually most of the people here explicitly wanted chaos and tragedy. So. Uh.

rmblr

  • Bay Watcher
    • View Profile
Re: The Roguelike Development Megathread
« Reply #1054 on: December 19, 2014, 04:31:19 am »

The API probably changed since the tutorial was written, that happens sometime. Try to find a a new tutorial, or downgrade your java environment to the version used in the tutorial
Logged

andrewas

  • Bay Watcher
    • View Profile
Re: The Roguelike Development Megathread
« Reply #1055 on: December 19, 2014, 05:43:31 am »

Looking at the source, there is also a constructor that takes a string and a Properties, so there is a version of the library that will compile. Sadly, there doesn't seem to be a method to attach the Properties after creating the interface, or any other way of specifying font and text size.
Logged

Adragis

  • Bay Watcher
  • Edgelady Supreme
    • View Profile
Re: The Roguelike Development Megathread
« Reply #1056 on: December 22, 2016, 07:03:45 am »

Used the python+libtcod tutorial (python v.2.7.12, libtcod v1.5.1), am developing a WH40K-themed roguelike. I currently have about twice the amount of code the tutorial has, which is good.
However, the tutorial's code is pretty messy and focuses on the small-scale, and the huge lists of items, creatures etc. which are defined as objects every time they're spawned occupy lots of space.
I've tried defining the definitions in functions, which works in-file but increases the amount of space used - I would like to store the functions in a module or some such. However, the module requires the main game to function, meaning it needs to import classes from the main game, which causes a reciprocating loop thingy (can't remember what the term is) which means it loads one before the other in the wrong order.
Any way to just define the items as raw text and feed that into my program, or a way to get the module working?
Logged
thincake

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: The Roguelike Development Megathread
« Reply #1057 on: December 22, 2016, 07:05:03 am »

You would normally use a JSON or YAML file to store data, and import it using a library.
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

Adragis

  • Bay Watcher
  • Edgelady Supreme
    • View Profile
Re: The Roguelike Development Megathread
« Reply #1058 on: December 22, 2016, 07:07:19 am »

I don't want to seem ignorant, but I'm fairly new to coding in general and only know a few tidbits about JSON files from Cataclysm. Can you tell me/link me to something useful?
Logged
thincake

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: The Roguelike Development Megathread
« Reply #1059 on: December 22, 2016, 07:20:42 am »

It's essentially the exact same syntax you'd use to define dictionaries and lists in python, but only with double quotes for strings, integers/floats, and booleans with lowercaes.

For example, your monsters.json file might look like:
{
    "snek": {
         "hp": 100,
         "attacks": [
             "scratch",
             "bite",
             "poison attack"
        ]
    },
    "dog": {
        "hp": 120,
        "attacks": [
            "hyper beam"
        ]
    }
}


Then you'd do, in python:

import json
with open("monsters.json") as f:
    monstersdata = json.load(f)
initializeMonsters(monstersdata)


and in initializeMonsters you'd translate the data from naive dictionaries & lists & primitives to whatever object-based storage system you use.


If you wanted to access the snek's attack #2, you would do:

monstersdata["snek"]["attacks"][1]

just like in Python.
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

Adragis

  • Bay Watcher
  • Edgelady Supreme
    • View Profile
Re: The Roguelike Development Megathread
« Reply #1060 on: December 22, 2016, 07:40:06 am »

When I say object, I meant a class defining an object in-game (which has other properties like item, equipment or what-have-you). Does the JSON thing apply there?
Logged
thincake

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: The Roguelike Development Megathread
« Reply #1061 on: December 22, 2016, 07:45:03 am »

Er, what's the problem here exactly?

Is defining all the items and monsters in your program making it annoying to scroll through?

Is your object list somehow using too much memory (RAM) and you run out?
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

Adragis

  • Bay Watcher
  • Edgelady Supreme
    • View Profile
Re: The Roguelike Development Megathread
« Reply #1062 on: December 22, 2016, 08:19:22 am »

Defining all the monsters and stuff in-program looks quite messy, yes, but the main problem is that when I'm making a custom map or making enemies drop items, I have to define the item again, meaning copypasting, and the list of drops will be the exact same code again, give or take a few things. So it's comparatively inefficient as well.
Logged
thincake

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: The Roguelike Development Megathread
« Reply #1063 on: December 22, 2016, 08:54:36 am »

The thing I mentioned would help with making your code look better, and is also good practice. Put data outside of code files.


About the inefficiency: is it noticeably inefficient? Are you using hundreds of megabytes of memory when you should be using 10? If not, don't bother fixing the inefficiency: it's not worth your time to fix it! When you notice that it's definitively a problem, though, then you could consider employing tactics like having a 'reference' and an 'instance'. Eg, you have a read-only class named Item, and another class called ItemInstance. Put all stats that don't change into the Item class, and put stuff that do change in the ItemInstance class. Say, the base cost of a potion as well as how much it heals goes into the Item class, and how much of the potion is left goes into the ItemInstance class. And then put a reference in the ItemInstance class to the Item one and look up static stats through that.
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

Xgamer4

  • Bay Watcher
    • View Profile
Re: The Roguelike Development Megathread
« Reply #1064 on: December 22, 2016, 01:38:15 pm »

Defining all the monsters and stuff in-program looks quite messy, yes, but the main problem is that when I'm making a custom map or making enemies drop items, I have to define the item again, meaning copypasting, and the list of drops will be the exact same code again, give or take a few things. So it's comparatively inefficient as well.

It's hard to know exactly what's going wrong here, but the fact that you're talking about copy-pasting things like monsters is... concerning. To say the least. Would you be willing to provide a snippet of your code showing the problem?

In general, you'd have something like monsters.py, that defines all your monster classes, and you'd just instantiate one of them whenever you needed one. So, you'd define a rat class, and when you wanted to put a rat in a map you'd just do r1 = monsters.Rat( ... ), where the arguments may (or may not) define things like max HP, current HP, status, etc - if that's how you defined the class.
Logged
insert something mind-blowing/witty here*
Pages: 1 ... 69 70 [71] 72