Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 18 19 [20] 21 22 ... 81

Author Topic: Cloud Scream > Development on Pause  (Read 86864 times)

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: WorldJem: Trainwreck...
« Reply #285 on: October 31, 2009, 02:52:12 pm »

Maybe have something like in DF, where water on the top level 'teleports' to available space beneath the last level of water.

But it would still have to calculate where the water needs to be, and have multiple bodies of water created
whenever the water is separated.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

Boksi

  • Bay Watcher
  • Everyone's dumb in their own special way
    • View Profile
Re: WorldJem: Trainwreck...
« Reply #286 on: October 31, 2009, 02:53:36 pm »

Put all the water tiles in a list and only check those tiles and the tiles around them?
Logged
[BODY_DETAIL:NAIL:NAIL:NAIL]
[HAMMER:HAMMER:HAMMER]

[TSU_NOUN:nose]
[SUN_TSU_NOUN:art:war]

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: WorldJem: Trainwreck...
« Reply #287 on: October 31, 2009, 03:01:09 pm »

Put all the water tiles in a list and only check those tiles and the tiles around them?
This would probably the be fastest solution as far as runtime FPS is considered, although it'd be a pain to set up...
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: WorldJem: Trainwreck...
« Reply #288 on: October 31, 2009, 03:15:16 pm »

Doubly linked list.
Just keep a pointer to the first and last tiles, and remember to handle the removal of the last or addition of the first case. Other than that, it's quick to append something( temp->previous=last;last->next=temp;last=temp; ) and deletion is as simple as (previous>next=next;next->previous=previous;remove current;, though if next doesn't exist, set the global last to previous, and if previous doesn't exist, set the global first to next. If neather exists, they would both be 0 or null anyway, so you don't have to handle that case specifically )

Just give each tile a previous/next pointer, and have a function to add and one to remove it from the list. And I reccomend using a doubly linked list, if you can handle it, since addition and removal is simply setting a few pointers, with all the (while(current){... current=current->next;}) of a singly linked list. Though if you only ever remove them from within a world update loop, singly linked would work just as well, I guess.
Logged
Eh?
Eh!

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: WorldJem: Trainwreck...
« Reply #289 on: October 31, 2009, 03:15:24 pm »

I don't think I'm up to it.
If that is the only way, it is going to take me forever.

The only way I could see that happening, is if somebody else helped me with it.

Otherwise, I'd rather drop super-dynamic water for now, and only have these calculations happen when
water is upset.
So a bunch of pre-existing lakes, and if you F with any of them,
there will be water flowing at around 10 FPS until the water resolves itself.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: WorldJem: Trainwreck...
« Reply #290 on: October 31, 2009, 03:18:14 pm »

I posted that before reading your post, but most of it is still true.
I would need help setting something like that up.
I don't know much about pointer systems at all.
Would I need to do object oriented programming to do that?
How would it keep track of each cell's variables independently?
I don't know much about this, sorry.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: WorldJem: Trainwreck...
« Reply #291 on: October 31, 2009, 03:45:14 pm »

Rather than looping an array, you would still have the array, but each element would have a pointer to the previous and next.(prev and next)

Code: [Select]
BlockType *first,*last;
void add(BlockType *a)
{
    a->next=0;
    a->prev=0;
    if(first)
    {
        last->next=a;
        a->prev=last;
        last=a;
    }
    else
    {
        first=a;
        last=a;
    }
}

void remove(BlockType *a)
{
    if(a->prev)
      a->prev->next=a->next;
    else
      first=a->next;
    if(a->next)
      a->next->prev=a->prev;
    else
      last=a->prev;
    a->next=0;
    a->prev=0;
}

You could also work by giving an array index, though it might be very slightly slower.

Also, those functions need a pointer, though as long as you can pass a pointer to them, it should be fine. If you don't know how, &(array[whatever]) works(if the array is of a custom struct, likely, and is not an array of pointers already, also likely).

Only problem might be if I am neglecting some C++ type safety feature, but it is unlikely.
Logged
Eh?
Eh!

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: WorldJem: Trainwreck...
« Reply #292 on: October 31, 2009, 04:37:54 pm »

I have an array called wat[150][150][150] that stores all which is water.
Different positions in this array contain the information, the rest have zeros in them.
How would I go about adding the positions to the list which need to be tested?
On top of that, how would I add a new tile to the list?

Can I give you the information you need, and you set up a system for me?
I will give you due credit.
I'm just not ready for a headache right now, and I would really like to get on with this.

I can keep programming as is, and when the system is ready,
we can add it in in place of the looping position system, boosting the FPS.
I don't understand a ton of what I see down there,
and I'm won't be in the right mindset to tutorial-chug any time soon.

Sorry everyone.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: WorldJem: Trainwreck...
« Reply #293 on: October 31, 2009, 04:48:22 pm »

Wait, are you storing the data as a base data type, or as a struct/class?

Logged
Eh?
Eh!

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: WorldJem: Trainwreck...
« Reply #294 on: October 31, 2009, 04:55:21 pm »

What the hell is a struct?
I've never used a class.

I have a header called "super_include" which contains over 300 global variable declarations.

:)

EDIT:
This is the part when we realize how basic of a programmer I am,
and some of you are inspired to follow suit with your own projects.
« Last Edit: October 31, 2009, 04:58:21 pm by Outcast Orange »
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: WorldJem: Trainwreck...
« Reply #295 on: October 31, 2009, 04:59:24 pm »

Oh. I think I know what you are asking.

It is called:

int water[][][];

Okay?
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

jplur

  • Bay Watcher
    • View Profile
    • http://www.parker-portfolio.com
Re: WorldJem: Trainwreck...
« Reply #296 on: October 31, 2009, 05:45:09 pm »

Well don't give up, I'm sure you will find the best solution.

If iterating through the whole array is taking too much time, maybe try storing a list of water tiles with their locations.

150^3 = 3375000 so yeah you would never want to iterate that realtime.

but if only 10% of that is water you could make a seperate list during generation, and sort it by z-depth.

Then you could use some tricks to cut down on iterating that list, like only checking the bottom zdepths, and teleporting the highest to empty neighbors.
Logged
I ended up finding out you can speed up pregnancies by changing the mother to a cat to knock them up and changing back before labor

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: WorldJem: Trainwreck...
« Reply #297 on: October 31, 2009, 05:50:50 pm »

I like that idea a lot more than anything so far.
I'll start thinking about a good method to do that.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: WorldJem: Trainwreck...
« Reply #298 on: October 31, 2009, 06:25:29 pm »

A list regardless would almost certainly require structs.

A struct is a custom data type. Example:

Code: [Select]
struct iDontCare
{
    int i;
    char string[32];
};
Is just an integer and a 32 char array.


The real benefit is when it comes to using an array of more than one type of data, or advanced data structures.

So, you would have
Code: [Select]
struct possibleTileType
{
    int type;
    struct possibleTileType *next,*prev;
};

The thing is, rather than refer to one like int, you must preceed it with struct. So
Code: [Select]
struct example
{
    /*some data stuff goes here*/
};
To make one, you would use
Code: [Select]
struct example variable;

For example, in a roguelike, if you want each floor tile to be able to hold 0 to 10 items, one creature, and it's character, you would use
Code: [Select]
struct mapBit
{
    char character;
    struct creature *occupant;
    struct item items[10];
};

struct mapBit[40][80];


Of course, I just realised that I forgot to mention how to access a struct.

It varies depending if it is an actual struct, or a pointer to a struct.

If an actual struct, to access property x of struct y, you use y.x
Example:
Code: [Select]
struct point
{
    int x,y;
}

int main()
{
    struct point a;
    a.x=4;
    a.y=2;
    a.x++;
    a.y-=a.x;
}

Very similar to a variable.


However, if you have a pointer, you use y->x rather than y.x
Code: [Select]
struct colour
{
    unsigned char r,g,b;
};

void setToGreen(struct colour *c)
{
    c->r=0;
    c->g=255;
    c->b=0;
}

I won't go into advanced subjects such as malloc() and stuff, but here is some quick example code of a 2D map

Code: [Select]
struct tile
{
    char char;
    float r,g,b;
};

struct tile map[40][60];

void draw()
{
    int x,y;
    for(x=0;x<40;x++)
    {
        for(y=0;y<60;y++)
        {
            glColor3f(map[x][y].r,map[x][y].g,map[x][y].b);
            draw_char(map[x][y].char,x,y);
        }
    }
}

Some more complex code uses typedef so that they do not need to use struct something to refer to it. typedef just tells the compiler that some phrase means something else, similar to #define, but just for types.

(Example from openGL header file)
Code: [Select]
typedef unsigned int    GLenum;
typedef unsigned char   GLboolean;
typedef unsigned int    GLbitfield;
typedef void            GLvoid;
typedef signed char     GLbyte;         /* 1-byte signed */
typedef short           GLshort;        /* 2-byte signed */
typedef int             GLint;          /* 4-byte signed */
typedef unsigned char   GLubyte;        /* 1-byte unsigned */
typedef unsigned short  GLushort;       /* 2-byte unsigned */
typedef unsigned int    GLuint;         /* 4-byte unsigned */
typedef int             GLsizei;        /* 4-byte signed */

Something somewhat harder to understand, but often used, is to combine the struct definition with the typedef, like this:
Code: [Select]
typedef struct whatever{} newname, newname2;or
Code: [Select]
typedef struct whatever
{
    int a;
    char b;
} newname, newname2;

However, since the typedef is incomplete during the struct definition, you must write out the full struct whatever for any pointers to the same type within the struct definition.



Now, I won't even bother trying to explain pointers, at least not in this post, as you *might* already understand them, and it's already so long...


Also, structs, or classes, are going to be essential for any sort of non-array list. And that wouldn'r be any diffrent from what you already likely have.
Logged
Eh?
Eh!

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: WorldJem: Trainwreck...
« Reply #299 on: October 31, 2009, 07:02:54 pm »

Thank you all so much!

Here is the new plan:

I'm going to stop work on WorldJem until I've mastered classes, structs, and pointers.
Then, I'm going to rewrite the whole thing with the new information.

Please bare with me through this learning process.
I promise it is necessary for the future of my projects.

I'll come back to this as soon as I know all of these things.
Hopefully it will only take a few days.
The major problem, is that my RL is getting pretty busy lately,
so it might be a while before I have time to put towards this.
I'm going to start picking apart the examples people have given me,
and learn them in and out.

I can do this.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream
Pages: 1 ... 18 19 [20] 21 22 ... 81