So I have been working on my program and I got a lot of work done. This feels like one of those days where i did a lot but i feel like i didn't go anywhere. So I'm able to get a workable release done by tonight but i'm not sure there is enough graphically changed to the program to be worth the release.
I updated the code/class for the information on the map.
Basically how i did it before was making 2 containers.
if you're smart, then you're added in to a list.
if you're dumb, then you're added to a list of a list
or thats the theory of how it worked.
After 3 and half hours of work, I shall list what it does while trying to sound smart.
<Note i get long winded and really the rest of this post is worthless.>
1 it makes three list. One for entities(smart/moving Objects), a list for Items, and a 2 dimensional array of ArrayList<Actor>.
I would first like to first explain the last part because it's confusing. So i will start with array. a Array is basically a address but can be used with any object type. It's more like a modifier saying that a address isn't for a house but a neighborhood. here takes this.
int yourAddress = new int(10302);
int your friendAdress = new int(10301)
int[] neighborhood = new int[2];
The top one that says "yourAddress", lets pretend your address is 10302 which is a integer but your the second house down in this neighborhood. I can add "yourAddress" to the a element/Location on the array which is the neighborhood. I can do the same thing on your friends address. This is sweet because I can do door to door marketing based on complete neighborhoods and i don't have to know what houses are there.
also just to note, computers think in two which is why we have odd numbers like 1024 MB is a GB. so this means 0 is considered a number. I think a byte(small amount a of data) can go as low as -128 and as high as 127. this is important because if your the second house in the neighborhood, then i would say
neighborhood[1]
if I was talking about your house. if i was talking about the first house i would say neighborhood[0]
a 2 dimensional array is is basically a array in a array. lets say you're playing tick tack toe. you got a grid that's 3 by 3.
int[][] TickTacToe = new int[3][3];
#012Y
___
0|123
1|456
2|789
X
if i want the information that 1 was at then i way say TickTacToe[0][0] but if wanted the information at 8 i would say TickTacToe[1][2. See how that works?
now lets move to array list. ArrayList is basically a list, clear and simple. It's a little different but i can't explain what it is without you being a programmer and likely i would have to be face to face. Just think about it as a list and forget the word array in the name.
____________________
Now going back to my program and how it works. Okay i have these three lists(basically there all list)
I take the items and figure out where they would be located and add them to the "2 dimensional array of ArrayList<Actor>." because they don't move and the list they were in was just short term.
The entities i keep where they are since they're likely to move.
Moving to the display code. (a bit of a display code);
I make a second 2 dimensional array but this time it's char which stands for character.
I then find out where all the entities are and put a char for the entity in the new array.
then scan the old 2 dimensional array of ArrayList<Actor>. and find where the items are in the room and place there char in the char array if the char doesn't equal any other value.
Sorry for this long winded end of the post. I'm really bored if you didn't notice... GIVE ME COOKIES or something. money would be nice to.... no wait i have no way to accept money.
Also i have a nice looking service that will allow me to sell any product i make, online.
I'm going to go to gym now.
No comments:
Post a Comment