Bomberman in xlib

A forum where you can announce your awesome project(s).

Moderator: MaxCoderz Staff

DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

well, you'd have several lists for the bomb data. For example:

L_X: x-coordinates of the bombs
L_Y: y-coordinates of the bombs
L_S: strength of the explosion
L_T: time left.
for simplicity, a variable, B, for the number of bombs (so you don't keep checking the size of the lists).

then every time you go through the main game loop (where you read keys and so on) you would subtract 1 from L_T.
I'd add a bomb at the beginning of the list, that way the bombs that explode will always be at the end where they can be removed easily.

Then to check if they explode:

While not(L_T(B
//explode bomb #B.
B-1->B
End

don't bother changing the size of the lists, that takes time, and it's not necessary.

then to lay a bomb, you'd do

B+1->B
X->L_X(B
Y->L_Y(B
etc.
just try to be nice to people.
_________________
My TI Blog - http://mpl.unitedti.org/
katmaster
Sir Posts-A-Lot
Posts: 252
Joined: Tue 09 Aug, 2005 9:34 pm
Location: south of the north pole
Contact:

Post by katmaster »

i dont think that works because of the the matrix data. your x and y coordinantes would be in the double digets, but the matrix would only be 1-8 for y and 1-11 for x.
cheese=yum
Image
katmaster
Sir Posts-A-Lot
Posts: 252
Joined: Tue 09 Aug, 2005 9:34 pm
Location: south of the north pole
Contact:

Post by katmaster »

necro wrote:in basic, the matrices go y,x as opposed to x,y...a source of many errors I have recieved over the time I have been programming
HOLY CRAP!!!! thats why its not working!!! thanks for that tip.
cheese=yum
Image
necro
Calc King
Posts: 1619
Joined: Sat 26 Mar, 2005 2:45 am
Location: your shadow

Post by necro »

yes, I still make that error frquently...but I can recognise and fix it is seconds anymore...any ways, your map can be bigger than the actual screen if it scrolls.
katmaster
Sir Posts-A-Lot
Posts: 252
Joined: Tue 09 Aug, 2005 9:34 pm
Location: south of the north pole
Contact:

Post by katmaster »

yah i know. i just got xlib 3 days ago and am still figuring out how everything works. ill get around to it eventually.
cheese=yum
Image
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

katmaster wrote:i dont think that works because of the the matrix data. your x and y coordinantes would be in the double digets, but the matrix would only be 1-8 for y and 1-11 for x.
Ok, then don't store X and Y, store your matrix coordinates. It doesn't make a big difference.


Edit: however, I was wrong, as long as you add new bombs at the beginning, you do have to change the list size, or else the list could well get to be really big.
just try to be nice to people.
_________________
My TI Blog - http://mpl.unitedti.org/
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

Just somewhere in the main loop you can do

Code: Select all

dim(L_X->B
dim( is used for getting dimensions or you can say

Code: Select all

42->dim(L_X
and change the list's length to 42. Extras will be cut off and new terms will be initialized as 0.
Image
katmaster
Sir Posts-A-Lot
Posts: 252
Joined: Tue 09 Aug, 2005 9:34 pm
Location: south of the north pole
Contact:

Post by katmaster »

DarkerLine wrote:Ok, then don't store X and Y, store your matrix coordinates. It doesn't make a big difference.
dang! why didn't I think of that? i must have been tired last night...
cheese=yum
Image
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

Really!? OMG I NEVER KNEW DAT BEFORE!!! :lol: :lol: :lol:

I was thinking that you wouldn't have to do that in this case... but as the bomb list is a queue rather than a stack, you do.

Edit: it appears this is my 256th post. And a poor excuse for one it is too.
just try to be nice to people.
_________________
My TI Blog - http://mpl.unitedti.org/
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

Yay I made a basic tutorial. :) . Trial and error (mostly error). dim( is great for saving games. say you want to know if they saved, never played beofre, or got a ram clear. Well you cant prompt em for what happened, its annoying.

So you use 20 terms of the list you save in, right? Well at the beginning of the code, say

Code: Select all

20->dim(LSAVE
If it existed it is unchanged, if it didnt, it does now and is full of 0's. cool eh?
Image
katmaster
Sir Posts-A-Lot
Posts: 252
Joined: Tue 09 Aug, 2005 9:34 pm
Location: south of the north pole
Contact:

Post by katmaster »

how would you implimint ai into this?
cheese=yum
Image
necro
Calc King
Posts: 1619
Joined: Sat 26 Mar, 2005 2:45 am
Location: your shadow

Post by necro »

You could create a little manager that cycles through multiple enemies...each having there own list elements and such, here is an example

Code: Select all

...PrgmENMYMNGR 
:For (0,A,N): “N being the Number of enemies 
:L1(A*4-4)->I 
:L1(A*4-3)->L 
:L1(A*4-2)->X 
:L1(A*4-1)->Y: “this stores a set of variables for each enemy 
:If I=1:prgmSLIME: “if it is a slime, treat it so 
:If I=2:prgmMNSTR: “If it is a monster… 
:I -> L1(A*4-4) 
:L -> L1(A*4-3) 
:X -> L1(A*4-2) 
:Y -> L1(A*4-1): “updates the list 
:END 
:RETURN... 
threefingeredguy
Calc King
Posts: 2195
Joined: Sun 27 Mar, 2005 4:06 am
Location: sleeping
Contact:

Post by threefingeredguy »

Theres a short BASIC AI lesson on www.calcgames.org, but I can't seem to find it. Look through some of the post from the last 2 weeks, it should be there.
Image
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

necro wrote:You could create a little manager that cycles through multiple enemies...each having there own list elements and such, here is an example

Code: Select all

...PrgmENMYMNGR 
:For (0,A,N): “N being the Number of enemies 
:L1(A*4-4)->I 
:L1(A*4-3)->L 
:L1(A*4-2)->X 
:L1(A*4-1)->Y: “this stores a set of variables for each enemy 
:If I=1:prgmSLIME: “if it is a slime, treat it so 
:If I=2:prgmMNSTR: “If it is a monster… 
:I -> L1(A*4-4) 
:L -> L1(A*4-3) 
:X -> L1(A*4-2) 
:Y -> L1(A*4-1): “updates the list 
:END 
:RETURN... 
1. you want to do For(A,1,N).

2. It's faster to a. use four lists and b. access them as L1(A), L2(A), etc. in the programs rather than store them back and forth.
just try to be nice to people.
_________________
My TI Blog - http://mpl.unitedti.org/
katmaster
Sir Posts-A-Lot
Posts: 252
Joined: Tue 09 Aug, 2005 9:34 pm
Location: south of the north pole
Contact:

Post by katmaster »

ok so heres my main loop:

Code: Select all

Repeat K or not(W or not(T   ;K= key press W=bombtimer                       
W-3->W                              ;T= enemy detection timer  ;when W=0 
getkey->K                           ;blow up bomb
T-1->T                                ;When T=0 move enemies
End
So is there any way to make this faster or am I the best :D
cheese=yum
Image
Post Reply