Bomberman in xlib
Moderator: MaxCoderz Staff
-
- Calc Wizard
- Posts: 526
- Joined: Tue 08 Mar, 2005 1:37 am
- Location: who wants to know?
- Contact:
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.
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.
-
- Calc Wizard
- Posts: 526
- Joined: Tue 08 Mar, 2005 1:37 am
- Location: who wants to know?
- Contact:
Ok, then don't store X and Y, store your matrix coordinates. It doesn't make a big difference.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.
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.
-
- Calc King
- Posts: 2195
- Joined: Sun 27 Mar, 2005 4:06 am
- Location: sleeping
- Contact:
Just somewhere in the main loop you can do
dim( is used for getting dimensions or you can say
and change the list's length to 42. Extras will be cut off and new terms will be initialized as 0.
Code: Select all
dim(L_X->B
Code: Select all
42->dim(L_X
-
- Calc Wizard
- Posts: 526
- Joined: Tue 08 Mar, 2005 1:37 am
- Location: who wants to know?
- Contact:
-
- Calc King
- Posts: 2195
- Joined: Sun 27 Mar, 2005 4:06 am
- Location: sleeping
- Contact:
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
If it existed it is unchanged, if it didnt, it does now and is full of 0's. cool eh?
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
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...
-
- Calc King
- Posts: 2195
- Joined: Sun 27 Mar, 2005 4:06 am
- Location: sleeping
- Contact:
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.
-
- Calc Wizard
- Posts: 526
- Joined: Tue 08 Mar, 2005 1:37 am
- Location: who wants to know?
- Contact:
1. you want to do For(A,1,N).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...
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.
-
- Sir Posts-A-Lot
- Posts: 252
- Joined: Tue 09 Aug, 2005 9:34 pm
- Location: south of the north pole
- Contact:
ok so heres my main loop:
So is there any way to make this faster or am I the best
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