Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: CrashIslands - a feeble attempt to create a survival roguelike and learn python!  (Read 2208 times)

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile

Hello everyone one, introduction stuff, etc.

I'm scrapping together ideas for a roguelike that's been itching to get out of my head. I've been playing Lost in Blue 2 for a little while, and the idea of a straight-up survival game has been clawing at my mind for the past few weeks.

So! I've taken it upon myself, with no real prior experience, to learn Python and libtcod and create the game!

I've got the .py file called IslandCrash, as a working title for the thing, and I aim to hit the depth of gameplay that Dwarf Fortress and Cataclysm DDA both have.

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile

Things on my To-Do list.
(In no particular order)

  • Figure out how to make a map scroll
  • Create a reliable spawn point
  • Get basic statistics down, character and environment
  • Create the island (Random?)
  • Figure out abilities and skills
  • How to carry and equip things

Things done
(In order of completion)

  • Get Python and libtcod
  • Study tutorial on Roguebasin (Reference material)

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile

Figure out how to make a map scroll
My usual way of doing this is making the map on one console, and then blitting that to the main console at an x/y inversely proportional to where you want to go.

Moving the the screen right means reducing x (the map is blitted further left, so it appears more to the right), and moving the screen down means reducing y (same explanation).

This will all still be theory until you have a better understand of python and libtcod.
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 /

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile

Thanks, I'm looking into that right now.

Are either Dwarf Fortress or Cataclysm real-time roguelikes?

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile

Dwarf Fortress is real time in places, turn based in others. Cataclysm is fully turn based as far as I can tell. Unless it's upcoming kickstarter will feature a real time goal ... (unlikely??)
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 /

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile

My usual way of doing this is making the map on one console, and then blitting that to the main console at an x/y inversely proportional to where you want to go.
The way libtcod handles its console data this isn't going to cause too much of a hit to performance, but it still isn't ideal.

Preferable way is:
1. Find the X and Y coordinates of your character.
2. From X, subtract half the screen width and from Y subtract half the screen height.
3. If X < 0 then X = 0, if Y < 0 then Y = 0
4. If X > (level width - screen width) x = (level width - screen width), if Y > (level height - screen height) Y =  (level height - screen height)
Steps 3 and 4 are often replaced with a clamp(x, min, max) function, but not required.
So this will get you the top left corner of where you need to draw. From there
5.
While (a < screen width)
 while (b < screen height)
  draw here! a and b are for the console and a + x, b + y are for what is on the map
  b ++
 a++


I realize that is somewhat poorly put, but if it doesn't make sense I can pull out some python and show what it looks like in code.

Are either Dwarf Fortress or Cataclysm real-time roguelikes?
Real time means that things don't wait for you to hit a button. So like how in Fortress mode where you can unpause the game and things will just happen, dwarves will wander around and things will attack them. In adventure mode if you don't enter a command, nothing happens, the world waits for you.

da dwarf lord

  • Bay Watcher
    • View Profile

AFAIK there is scrolling map code that goes with Jotaf's tutorial on Roguebasin, in one of the extra's sections, I'm not sure if there is an explanation of the code but It's all there and I think it's commented.
Logged

zombie urist

  • Bay Watcher
  • [NOT_LIVING]
    • View Profile

I aim to hit the depth of gameplay that Dwarf Fortress and Cataclysm DDA both have.
If you don't have any real experience, I strongly advise you not to aim for this much content.
Logged
The worst part of all of this is that Shakerag won.

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile

I aim to hit the depth of gameplay that Dwarf Fortress and Cataclysm DDA both have.
If you don't have any real experience, I strongly advise you not to aim for this much content.

Much of the depth in gameplay in Dwarf Fortress has to do with jobs and the history - And the one I'll be emulating is the jobs. Construction, cutting down trees, skinning and butchering animals...

In Cataclysm, I like that they give you the option to build walls and ceiling/floor combinations. Those are tile definitions that need to be swapped around.

I'll be doing this slowly, I only have chunks of time throughout my summer week where I can work on this, and a lot of that work will be getting the map and player up and running first.

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile

So, I have this chunk of code, a part of a tutorial on making a dungeoncrawl roguelike that I've modified to have an "open" environment.

This bit makes square rooms, hollow on the inside, and I'm trying to isolate "room.x1" "room.x2" "room.y1" and "room.y2" in order to create a "door" opening in each of the four cardinal directions.

Code: (making a room) [Select]
def create_room(room):
    global map
    #go through the tiles in the rectangle and make them impassable
    for x in range(room.x1 , room.x2 + 1):
        for y in range(room.y1 , room.y2 + 1):
            map[x][y].blocked = True
            map[x][y].block_sight = True

#Now make the interior passable
for x in range(room.x1 + 1, room.x2):
    for y in range(room.y1+1, room.y2):
    map[x][y].blocked = False
    map[x][y].block_sight = False

Here's the Rectangle class used to build the rooms.

Code: (Rectangle class) [Select]
class Rect:
    #a rectangle on the map. used to characterize a room.
    def __init__(self, x, y, w, h):
        self.x1 = x
        self.y1 = y
        self.x2 = x + w
        self.y2 = y + h
 
    def center(self):
        center_x = (self.x1 + self.x2) / 2
        center_y = (self.y1 + self.y2) / 2
        return (center_x, center_y)
 
    def wall(self):
        left_wall = self.x1
        right_wall = self.x2
        top_wall = self.y1
        bottom_wall = self.y2
        return(left_wall, right_wall, top_wall, bottom_wall)
 
    def intersect(self, other):
        #returns true if this rectangle intersects with another one
        return (self.x1 <= other.x2 and self.x2 >= other.x1 and
                self.y1 <= other.y2 and self.y2 >= other.y1)

As you can see, I've tried defining each wall seperately, but I can't figure out if it's right or how to pull those variables out.

EDIT: Ahah, got it. I put a self.xc and self.yc to give me the centerpoint as a variable in the class, and I took the self.y1 as a co-ordinate to place the door in the exact center of the room!

Now that I've got it figured out, I can make sure there's always an exit north of my spawn room, and that every other room has at least one exit. debugging for blocked walls will come later.
« Last Edit: June 14, 2013, 09:44:33 pm by Pufferfish »
Logged

smaadmin

  • Bay Watcher
    • View Profile

Curiosity keeps me to be watching how this will develop :)
Logged

Gentlefish

  • Bay Watcher
  • [PREFSTRING: balloon-like qualities]
    • View Profile

Island generation's out of my reach currently so I'm gonna design a roguelike version of minesweeper for now. It'll help me learn tile properties. Whee!

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio

Libtcod makes island generation a breeze. Just take a Perlin noisemap, translate it a bit, multiply, and set everything under 0 as sea/water. Voila!
Though this isn't optimal for continents, it makes convincing archipelagos. That's how I did my own terrain gen, though with libnoise instead of libtcod to avoi being tied too closely to libtcod.
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