Re: TIB: rpg game


[Prev][Next][Index][Thread]

Re: TIB: rpg game




ETTamme1@aol.com wrote:
> 
>         As to the level storage,  I am working on that, but i will throw out some of
> my ideas for you do chew on. the first and most obvious idea is to store every
> level in a matrix but i soon realized that would eat up WAY to much memory.
> The second idea is to store the levels into the existing matrix ; it would
> work like this, there are 128 segments to the screen 8x16, so you would have
> to store each set of coordinates on the matrix , now, each storage can consist
> of no more than 8 bytes at 1 byte per character exe.    3  ->  [C]  (  8  ,  1
> 6 , so 8 bytes per storage, multiplied by the 128 segments 1024 bytes per
> level.  This compares to 1160 bytes per level for the pre stored matrix. Not
> to metion that the manual storage mode is within the program so it will slow
> it down, so now im back at square one with pre made matrix levels.  The last
> idea I have, is that i could develope som kind of equation that when repeated
> over and over it wil take the previous answer and put into the equation again
> to get the next number to store in the matrix so it would be a looping thing,
> but i really dont know how i could do this without making some kind of
> noticeable pattern.  I did just come up with another idea while typing
> actually so its kind of in a raw state but here it is, it would be kinda like
> writing the matrix to the screen to get the coordinates for the matrix ,
> alright here it is;  its a loop that repeats untill  x=129    x+1->x  get the
> next set of coordinates so the first one would be a,b then say
> expr(sub(Str1,x,1)->[C](a,b)  end the loop then add one to b and when it gets
> to 16 store 0 as b and add 1 to a this way you are using a string to write the
> matrix (which will take less space), and since it is looping and not each
> individual set of coordinates it will only take up like 100 bytes for the
> actual programming but you will have the space of the string (136 bytes for
> 128 numbers) for a total of about 400 bytes per level in risidual levels plus
> the original 1160 bytes of the matrix which will now act as a level host
> actually so say i have 10 levels 400x10 4000 plus 1160=5160 bytes for every
> single level in the game.  I think thats decent considering i could have half
> that many levels for the same memory using any of the other systems (excluding
> that equation one but i dont know if thats doable).  And, you have to take
> into account that this system does not take up more than 200 bytes of program
> space so it will not attribute to slowing the program down.  Ohh.......  Can
> you use the numbers in the string as actual numbers or are they interpeted as
> "symbols" after they are in the string......???? never mind i just checked you
> can.  I think that this is a good way to change levels, but it does require
> using the dreaded MATRIX dun dun daaa..... Let me know what you think

I like that idea.  Why not eliminate the matrix entirely and just go
with the string?!  Instead of storing things to a string and then having
to read off the string and into the matrix, just base everything in your
program directly off the string.  I don't know if that would effect the
efficiency too bad or not?  Anyway, by using some modular arithmetic you
could pull the correct number out of the string, and then check it just
like you check the matrix now.  For example, say that the first sixteen
elements in the string represent the first row in the matrix, the next
sixteen represent the second row, and so on.  Also, assume only one
level for right now, just to keep things simple.  You also know what
your position is in terms of C and D.  All you need to do is pull the
number out of the string that is in the D spot, after you correct for
what C is.  Think about it.  If you are on the second row from the top,
C=2 and D=some number between 1 and sixteen.  Let's say D=8.  You now
know that you need the eighth element out of that group of sixteen
numbers.  Of course if you just take the eighth element of the string
you will be getting the number that is one above where you are.  What
you actually need is the sixteenth element of the string; which is the
eighth element out of the _second_ group of sixteen. Perhaps I can show
it better.  Here's what your matrix looks like;
[4 4 4 4 4 4 4 5 4 4 4 4 4 4 4 4 
 4 4 4 4 4 4 4 5 5 5 5 4 4 4 4 1...]
Turn this into the string;
:"44444445444444444444444555544441
Now picture this string as two groups of sixteen
:"4444444544444444 | 4444444555544441
Your D value tells you how far into the group you have to go to get the
correct number.  But which group?  That's where the C value comes into
play.  You have to use the C value to calculate how far.  If C=1 then
you are dealing with the first group - which starts at the first element
of the string.  If C=2, however, you have to start with second group -
which begins with the seventeenth element of the string. The starting
position of the correct group can be found by using the formula
16(C-1)+1 [which simplifies to 16C-15] Now you know where in the string
you are dealing with, all you have to do is add the value of D to this
number and you should be at the correct number. Oh, acutally you have to
subtract one from the 16C-15 because D will never be less than 1. 
Anyway, I think the final equation is 16C-16+D.  Therefore, you simply
need the command;
:expr(sub(Str1,16C-16+D,1 
to get the value of the number at the position on the screen.
To add more levels simply add them on to the end of the string.  You
will need to add something into that formula to account for which level
you are on.  I mean, if you are on level two, the formula, as it stands
right now, would find the number for level 1.  Let's see, I'm going to
use the variable L to represent what level you are on - first level L=1,
second level L=2....Since there are 128 elements in the string for each
level, you will need to add 128 to your starting position for each
level. 128(L-1)+1.  Again this needs to have 1 subtracted away because
the previous formula already compensates for the first element. 
Therefore, (128L-128)+(16C-16+D) should give the correct position.
Simplify...
128L+16C+D-144 should do it.
:expr(sub(Str1,128L+16C+D-144,1
Keep in mind that I've just been doing this as I've been going along at
my computer.  I haven't actually had time to sit down and try any of
this.  Put simply, it might be wrong. 

Jody Snider
jody1@alaska.net


References: