Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Subtanks project

Author
Message
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 7th Jun 2004 16:14
Hi there, I did try to write a 3d game that was tilebased. Having a problem with making the cube move according to the tiles i asked here in the forums. SandraD and I got along very well in the discussion and we did continue the discussion after the problem have been solved.

Now I starta a new thread as i no longer need help with making my cube move . However, let me point out a few things:

- This is no tutorial (altough please learn from it as i do )
- This is no team request
- This is supposed to be nothing more than fun and helpful.

With that said, heres the current code:



This is the code as it is so far, the cube now moves nicely along the tiles and were just about to try to ad collision detection with the other cubes and make it stay in the world.

Another thing, it doesnt matter if you have DB Classic or DB Pro since I have Pro and SandraD have Classic the discussion will be adepted to both version anyway.

Im excited about this Please tag along if you think it sounds fun...

To start of, anyone have an idea of how to implent collision detection?

Dreaming of creating a highly advanced AI mind
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 7th Jun 2004 20:33
I'll add some collision in, just gotta finish this english essay

Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 7th Jun 2004 20:41
Nice B).

The way of loading a level, data statements 1's and 0's, did i get from Scouseknights pac man tutorial. I was just about to start reading how he did collision detection.

Looking forward to a collision detection discussion hehe

Dreaming of creating a highly advanced AI mind
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 7th Jun 2004 22:12
Argh, sorry don't think i'll have time right now, but to get started the way i'd do it is:
Have an array which is the size of the number of grid squares in the level eg Collision(worldwidth/10,worldheight/10) then fill the array with 1's and 0's based on wether there is a block on that tile.
Allow the player to make a move but before finally positioning the player check it the square its moving into isn't occupied by checking it in the collision array. This will involve keeping track of which grid square th eplayer is in aswell.

Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 7th Jun 2004 22:26
Hmm... thats kinda smart... Ill see if I can get it to work

Dreaming of creating a highly advanced AI mind
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 7th Jun 2004 22:58
Hmmm... I think i did something wrong.

What i did was, in the load level func where all the cubes are placed i also set the tilestatus(x, y) to 1 if there was a cube or 0 if there wasnt.

Then before i set the direction in the player input func, i test if there is something in the adjacent tile where the player wants to move. Only if that tilestatus(x, y) is 0 the direction is set.

However, it didnt work. So i added those variables to my debug func print status. It turned out that those variables had some wacky numbers .

Anyone know why? Heres the code:


Dreaming of creating a highly advanced AI mind
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 8th Jun 2004 01:39
Well, I made it....

First off, I don't think I'd use a "1" for for anything but the non-movable "sides" of the game world, just in case we want to include other things that can be "pushed" as we said earlier. That way we can detect if an object can or cannot be moved by its type. But you are correct in assuming that the current movement code should detect zeros before allowing a move to take place, though it sounds like you didn't quite implement it right. (Haven't read the code yet, still waking up.)

Part of my thinking is -- the data statements themselves contain the 1's and 0's to create the world itself, why not simply copy the value read into the tilestatus(x,y) array instead of using an assignment? That way, should we want the objects in the plane to be movable (object type #2) we simply place a 2 in the data and it gets sent directly to the array. Makes building the world a whole lot easier.

Now, as for why it didn't work...

Again, I haven't look at the code yet but it could be the manner in which you're aligining the current position to the matrix, which I have seen before myself. There are generally two ways around that; the first is to keep a set of variables like Player_X and Player_Y for pointing into the matrix, or keep the player position and the world aligned so these can be computed. Once I wake up I'll look over the code and find out which you've used, then get back to you.

ttfn,
S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 8th Jun 2004 02:02
Hahahahahaha!

It's "kick yourself time" again my friend!!

That's right, you messed up in a big way by small assumption...




Tell me, what's pos_x(object)/10? It's the Matrix Value of the X position. Right? Now what happens when you add 10 to it?

the lines SHOULD be;



and similar. Not adding 10, but adding or subtracting ONE.

hehehehe. You got thinking "position" and didn't think matrix steps. Easy mistake, but it causes problems.

S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 8th Jun 2004 02:35
Okay...

Tell me; what's mazey in the world build code?
No I'll tell you; Error! It's always zero. No wonder you couldn't hit nothing, you weren't setting array values. (heh-heh.)

The corrected code is at the bottom, including my change for the world build code to allow objects of different types allowed into the matrix. I also changed the globals to arrays for DBC, though I've had troubles with using DIM and array referred values so the world matrix uses constants.

I also added a new scancode detection to the camera variant code, to temporarily display the tile status matrix on the screen for testing.

Code follows, ta ta for now...
S.



Oh yes, I almost forgot, I changed the status display to show Matrix Steps, not true X-Y anymore.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 8th Jun 2004 03:00
Okay, new problem here.. the world array isn't big enough. Or truly, it's not deep enough.

Since we are using direct objects in this code, we need another layer to the world array, to save object numbers along with their type. Otherwise, as we have the code now, we can't know for sure which object has blocked us in case we want to move, or remove, it.

Now, we could do that with another array of the same size of the world, or just add a new dimension to the present code. I'll let you decide. The code changes would appear as;

New Dimension;
dim tilestatus(20, 20, 1)
tilestatus(pos_x(object)/10+1, pos_z(object)/10, 0)=0
(plus new code--editing the rest for the 3rd dimension as above)

New array;
dim tileobj(20, 20)
(plus new code)

(The new array seems best to me, don't have to edit all those old lines!)
S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 8th Jun 2004 06:25
Okay, so I couldn't wait....

This version of the code allows to move around any class 2 objects... just like I was talking about. This one uses the new array method, since it was easier.



S.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 8th Jun 2004 12:36
Hahaha *kicks myself* Never, never, never code when youre tired!

Hehe, I go to sleep and you rewamp the entire good? Hehe... good You did so much changes so I saved this code under a new project name...

In this part:



At the last endif i get that ******* command out of place for that endif... Stupid editor. Anyways, I come straight out of bed now so Ill try to wake up and then figure out something that _I_ can add to the code (whitout messing something up that is)

Dreaming of creating a highly advanced AI mind
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 8th Jun 2004 13:05
Ok, I updated my IDE, that was the thing

Anyways, Ive looked though most of the code and it looks good. However, the blocks at the borders block movements but not those in the middle... which youre supposed to be able to push. The 2's B)

I have yet no idea why and im already late for school.

See ya later

Dreaming of creating a highly advanced AI mind
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 8th Jun 2004 16:52
Hmmm....

I don't know why you say that. My world map looks like this;

data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,2,0,0,2,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

And only the Class 2 objects can moved around. (So the lone standing block cannot be moved, but the others can.) But then, we've had a problem with those ENDIFs between versions so that might the thing, but it is annoying. It's like the section you mentioned, if I don't include the endif just before the move() function exit it falls to the end of the program and screams "nesting error!"

Dunno where that's coming from...


However, on to bigger and brighter things.

It occurs to me now that we've taken this code just about as far as we can for now, for if we start to add in self moving objects (such as a marble that's been pushed and must roll until it hits something) then we need yet another array to hold the fact that is is moving, and where it's going. So it seems to me about time to re-think this and work out some new code, because this control scheme is going to get messy during any further additions.

As the tutorial says; plan it out before coding.

S.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 8th Jun 2004 17:36
Ive updated mu IDE so that endif bug seems to be gone... for now

So you can push the blocks around? I cant

Ill keep going straight trough them! Only when there is a block behind them, which is tested because in case it is we cant push the block, if there is Im completely stopped.

Hmm... Could you sen me you code again? In case Ive edited something away I added a few spaces here and there between lines when i read i because I think its easier to read it that way

Heres my code... well, your code i mean you wrote it


But what if we do plan before we code we state all the features and make some kind of goal or design document. Maybe even a flowchart . I dunno, sounds cool i think.

Dreaming of creating a highly advanced AI mind
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 8th Jun 2004 18:17
Hmm....

If you're going right through them then the A value of player_input isn't being passed, (or set) or the object2 is not being detected as non-zero in move() by the if..then. I use <> for not equal, so I dunno where that error is coming from. I'll re-post the code at the end here.

(Oh yes, try pressing backspace to see if your array is being filled properly. It'll show up on screen as the world map.)



Otherwise, my proposal for the new code is thus...

In order to preserve as much of the existing code as possible while allowing for a greater range and type of objects, we need to do the following;

1. Expand the movement control arrays to cover all potential objects, in this case 400 of them including the 20 allowed for players. In this way, each object would be referred to by number as to whether it is moving or not, and where it's going and in what direction.

2. We separate the move destination calculations from the movement function, preferably placing the current code into a function called destination() for the player_input() to call. This would allow a call from the move() operation for already in motion objects, making a rolling object update its destination as long as the way is clear. (More below.)

3. Move the move() call from the input function to the main loop, where all objects that are moving are updated before sync. This means that move will become our most major operation, in that it updates each object's position and decides when they reach their final destination.

4. Create a function called ismoveable() to detect objects behind moving or pushed ones which would return a flag to move(), destination() and player_input() to call. This allows us to stop movement once it has been set.

If this sounds like a lot, it's not really. Just a lot of re-organizing of what we already have. I hope to have an example of this pretty soon for you to look at, but as my day is reaching an end it'll be at least tomorrow before I get there.

Good night, have a good day.
S.



Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 8th Jun 2004 21:24
I agree.

Lets start of with your first point. If everything is going to be represented by code numbers, quite logical i think , then we must decide in which boundries all objects must stay. To start of, which numbers are the players going to have?

Another thing... How are we going to store all the info? Is one huge array all we need? First element is the unique number for each object, the second is direction and so on. I think that we, for the sake of flexibility, make one array for each type of object. I mean the players have later probarly more attributes to keep track of than the static cubes . And if we decide to implent some kind of enemy that we put between 25 and 30 in the huge array. What if we come to conclusion that we need 20 enemies? Then all the boundries must be raised... not good.

Onwards, you sound like you have quite an idea of how to make the game engine now. I like it so far should we map out some kind of flowchart? Or you maybe have it crystal clear in your head I dont however hehe not anymore .

Also, should we decide where we want to take this game? I mean in the end term what features we want and taking steps towards that goal. Or should we do as we do now, just trying to get everything working around the game engine. And then decide if we want to expand the project to an entire game or leave it as it is and start on something else.

Im trying to get my ISP mail working, hotmail isnt that reliable when it comes to file attachment. Its also quite slow .

For the gaming part, I havent yet checked the problem in detail that made it able to go through blocks. As I said i can freely go trough them in both angles (x and z) as long as there isnt another block behind it.

Also the blocks in the middle is of the grid! I saw it now, i dont know why. Theyre like... distorted, a bit thrown around. I did take screenshots but I dont know how to get them to you. My ISP provides me with some FTP space, we can store some stuff there. If FTP would be of any use I mean.

Im not going for a record breaking post here, i just got much to say . Well there sounds like there is some planning to do and some decisions to make before we go on coding.

'Til next time!
Mizipzor

Dreaming of creating a highly advanced AI mind
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 8th Jun 2004 23:20
Okay, last first...

1. I didn't notice any distortion myself, but then I've been setting my screen down to 800 by 600 at 16 bit for speed of movement. I'll look more closely next time I'm in the program, but I didn't see anything 'glaring at me' like that.

2. FTP? Possibly of use. It would make another place to swap the code and screen shots and such. Though I rather enjoy that folks can both read our code and our mistakes along the way here, for if nothing else, maybe it'll become a tutorial of how you have to notice those little things when your program messes up. And of course, a testament to not give up if it doesn't work even the 500th time. (heh-heh)

3. As for going through the blocks, I don't know why this happening. If fact, after I created the new sections I was enjoying pushing the six moveable blocks around, making them into different kinds of figures and breaking them apart, such like that. Just had to be careful to not push them into cube though, or up against the sides. Then I lost them because you must have an empty space on their far side to push them. Wonder why yours is letting you pass through them???

Just for kicks, try putting parenthesis around the terms of the AND lines in the input section. I.E. From;

if tilestatus(x,y+1)=2 and tilestatus(x,y+2)=0

to;

if (tilestatus(x,y+1)=2) and (tilestatus(x,y+2)=0)

or even;

if ((tilestatus(x,y+1)=2) and (tilestatus(x,y+2)=0))

I don't know which editor you're using but from the differences we keep seeing I wonder if yours is trying to "add in" commonly forgotten words like THENs and ENDIFs and such. If that's the case, the line may be read as IF (first term) THEN (second term ) or something. Like I said, I don't have a clue...

4. Where to take it? Well, I don't know exactly yet. I have some odd images in my head that pop up from time to time, like one this morning was; what happens if we push a block on top of a geyser? Then I can see it flying through the air to land on something else in the grid.

So I really don't know yet, haven't quite thought it through that far. As for expansion, I can see it as a puzzle or action game eventually, once we work out the incidentals.

5. Making a game engine. Yeah, I have a small amount of experience in this stuff. I've been programming for a very long time and a part of that has been games and simulations. In fact, I often suggest that new students of programming start by doing games, simple ones that allow them to get into the language and not worry about math or technique so much.

Now, as to a flowchart--that might help. However the chart would be more useful in the areas of the move(), destination() and ismoveable() operations I described, for those are the heart of the game itself. However, to counter that statement I would have to point out that it would not be a flowchart so much as it would be a state-chart, since we have different 'classes' of objects doing some things at the same time that other objects are doing different things. So a flowchart of the operation would be mostly a huge decision tree. (As the code will be eventually.)

6. Storing the info. According to the way you started the program and my latest addition, we have 7 (count 'em SEVEN) arrays storing our object data, which I propose to reduce to six in the next revision. While the size of these arrays presently is "over-kill" given the expected number of objects that actually move in the game, the code for reducing this number would mean trashing most of what we have, and possibly slowing down the result if we implemented it. So for the time being, given our world size and all, the expected amount of memory available to us and such, I have no plans for changing this.

As for the enemy, when we have made space for 422 objects and we know -- already -- that 78 of them don't move (the edges of the world) there is more than enough space for enemy storage.

And when it comes to making an array for each object or type, then you trash the world map and it must be built all over again. Not to mention it has to be outside now, where it can define the arrays required on the fly, then link them into the movement code. All in all, it may be more hassle than it is worth.

7. Object numbers. Wrong wording on my part. I meant Object Types. What I mean is; currently Type 1 objects are fixed, either part of the border around the world to keep everything inside, or an obstacle inside the game surface. Type 2 objects are cubes that can be "pushed" providing nothing is behind them, while Type 3 let's say will be marbles that roll. This data goes into the world map array itself.

Now, where the object numbers come in is BEHIND the world map, in an identical sized array that stores the object number assigned by Dark Basic when we create the image. That way, the TYPE tells us how to move the object, and the object number tells us which image it is. The only potential exception to this rule is in that of enemies, or those locations in the world map where X=1, Z=1, X=20 or Z=20. That is easily detectable to give us a "scratch pad" where we can save the data needed transitory objects or enemies, so I doubt we'll run into problems soon. And, in the way the code is built, we just need to change two global variables to re-size the world, offering new locations for everything.

So there you have it. I know I said I was going to bed but I haven't yet, just too wound up I guess. (Too much coffee maybe.) Now I think I'll go try to lay down again, have a meeting to go to tonight...

TTFN,
S.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 9th Jun 2004 00:58
I got DBPro version 1.052. Thats both the language and the editor version, right?

Youre absolutely right that other members should of course be able to see the screenshots we discuss. If i get that FTP working, I could code an index.html and place it there along with the two images. When entering that FTP trough a browser the index.html will be loaded as a webpage. That html document could be coded to just show the images .

But for now im totally stuck on getting that pushing thing to work for me as well as it does for you. But as we are approaching the outer limits of my programming skills its getting harder and harder to tackle the problems . This is after all like my first real project. Up until now Ive only been doing small example program to try out new things i learn.

I cant figure out something else it could be besides the editor or the language version that screw it up. We ran the exact same code after all .

Anyways. Im going to look trough the code again and see what I can find out.

Wish me luck!
Mizi

Dreaming of creating a highly advanced AI mind
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 9th Jun 2004 01:04
WOA!

You know what i JUST found out? I tell you, the distortation i was talking about. That the blocks werent exaclty on the grid. Well they are. When you first run the program. But everytime i run trough the block I "push" it about one or two world units! Creating that distortation i was talking about.

I dont know why this happens. That i am able to run trough the block and also push it... and then not even the full length. Maybe i should start thinking about that testament .

Ill try to see what I can find out about this bug. But at the first glance, it doesnt look bright .

Dreaming of creating a highly advanced AI mind
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 9th Jun 2004 04:48
If you're only pushing them a little way it's that IF OBJECT2 <> 0 THEN stuff in MOVE(), though why it's causing this I don't know. Try paren'ing the term(s) where we use math on the new position and for the tested value of object2<>0 and see if that helps.

If not, much as I hate to say it, take out the THENs and structure the lines as IF...ENDIF. So far, our most common experience has been that THEN/ENDIF is giving us problems, such that your editor or version is mucking around with the two.

good luck!
S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 9th Jun 2004 04:51
Oh yes, and as for the distortion/movement question on my end, I tried 640x480 all the way up 1024x768 and saw none of it.

I got woke up by a phone call... thought I'd check your efforts. Now it's time again to test my eyelids for holes... If I can get back to sleep that is.

S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 9th Jun 2004 05:27
Wait a minute... Wait a minute... I THINK I GOT IT!

It occurred to me while I was lying down and trying to go to sleep, thinking of your problem with passing though objects. (Looking over source.) Yup, that's GOT to be it! Do this instead;

1. Up with all the others, add the line;
DIM A(1)
2. In EACH case where you see A in the player_input section, replace it with A(1)
3. Run the code.

The the problem you see is that A is a LOCAL VARIABLE to the function of player_input(), which DBPRO trashes at each pass through the loop. It appears that DB Classic isn't as good at "garbage collection" and freeing up the used memory, so my version worked because the value of A was retained when it hit the main loop. Yours was automatically going back to zero.

Problem solved!
S.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 9th Jun 2004 12:52
Yup thats it

Hmm hehe... what to do now?

If I may come with an idea, how about moving to game to the y axis to? Still as tilebased. Say something hovers in the air. A good weapon for multiplayer, or the levels exit, or some kind of needed rescource. Then you have to push the blocks around to build some kind of tower. Then we add a third kind of block, a STAIR , we need to be pushed adjacent to the blocks that form the first floor of the tower. And so on until the player reaches that high.

But then i got the idea... that kind of tower building operation is going to be hard becuase youre going to need pretty many blocks to form a level big enough so you can push an object around. If we make so the player _carry_ the blocks instead. Press space and the block attaches itself to the player. This will make it easier to rotate stairs also.

One more thing. Those for tilestatus variables we have. Why not make a radar out of it? With color code for empty, solid and pushable.

Im going to start write some code now hehe .

Dreaming of creating a highly advanced AI mind
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 10th Jun 2004 07:12
Well yes, I did expect that we would be "breaking the pull of gravity" rather shortly in this code, as we attempt to re-organize it for clarity and greater numbers and types of objects. I'm working on those changes that I mentioned earlier in the thread, and the result is promising if taking a little time. However, since I've already had to expand the arrays a little to get the new code to function properly, I suppose I might as well add the Y axis stuff in there as well. (Keeping with the general nature of the code you started though.) Like I said, I'll let you know...

S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 10th Jun 2004 15:39 Edited at: 10th Jun 2004 16:43
Okay.... Here we go.

I hope this doesn't confuse the heck out of you when you look at it, but this is the new code I've been working on. At present I've not included any more than the three object types we have, namely the player, moveable blocks and unmoveable borders. (Objects -1, 2 and 1.) Though I have included a Y axis movement option, using codes 5 & 6 for up and down, and (currently) 5 layers of depth in the "world." Though only layer #1 is filled with any map detail at this moment.

Also, I added a "movement que" to the move() function, in that objects that are in motion are listed in a circular buffer for move() to process. Currently up to 210 objects can be in motion at any time, which seems like enough.

Anyway, look over the code and see if you can make heads or tails out of it, then let me know. I don't believe I've made any mistakes in the locals this time, so it should run okay for you.



Oh yes! I also changed the SIZE and SCALE of the world in the process, because the old value of 10 pixels per unit was unviable for changing speeds. What I mean is, given the step distance you had programmed, and the speed values possible, 10 gave us the possibility of setting speed to 1, 2 and 5 only.

How did I arrive at this? Think about it a moment. If speed is set to 3 the first step will be 3, the next 6, the next 9, the next 12. The result; the cube will "hop" back and forth from 9 to 12, 12 to 9, etc. as the move() is being processed.

So, I changed the scale to 12, which allows speed values of 1, 2, 3, 4, and 6. Even used 1 & 2 in the code, try it and see.

TTFN.
S.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 10th Jun 2004 15:49
DIR is a function in DBPro :/, so the name cannot be used for an variable .

Ill try to see if I can spot all the places its used and rename it.

Dreaming of creating a highly advanced AI mind
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 10th Jun 2004 16:40 Edited at: 10th Jun 2004 23:35
Oh... ouch!

Okay... I wanted to edit the posting anyway... forgot an ENDSELECT in it. (must remember to save before exiting... )



Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 10th Jun 2004 16:46
Or yeah, that one also has a sphere object in it.. which currently acts like a cube you can push.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 10th Jun 2004 17:27
I got "Unknown parameter at line 445", deque dont know why. Im still trying to understand the code . As we are at the mere limit of my programming capabilities i feel i cant contribute as much more to the project . But well, by this i learn... and thats why i started doing this B) hehe...

But could you describe in little more detail what every functio does? And then i maybe have it easier to puzzle it all together .

Dreaming of creating a highly advanced AI mind
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 10th Jun 2004 23:43
That's okay, I needed to re-do the deque() function anyway... Don't know why it claimed the error however. Like we've noticed, there seem to be problems with nesting if..endif and such like that.

Anyway, try this one out and see if it helps. It doesn't solve all the problems as yet however, in that multiple objects can collide on a particular matrix location and one will "over-ride" the other in an unpredictable way, but it's a start. Providing you can get it working for you that is...

So give it a try and we'll see.
S.



Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 11th Jun 2004 08:26
I really hate "throwing code" at a problem such as this one, but until I sort out the problem, I guess it'll have to do. But this snip seems to work for the time being.

The trouble you see is that the sphere object can "keep rolling" after it has been pushed, until of course it hits something. Trouble is, since I made the player able to "catch the ball" by having a faster speed, you can "claim the square" where the ball is going and then it disappears off the world map. Unacceptable.

So, I thought to "made the ball wider" in the direction it was traveling when it is pushed, which seems to work but is somewhat messy. Anyway, here's the code...



If anyone as a better suggestion given our combined source in this thread... please shed a little light on us. Thanks.

S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 11th Jun 2004 12:37
Okay, big changes time...

In trying to get a little vertical movement and such added to this whole mess, I have decided that we'll need an array to store the tile symbols of all moving objects. However, to really be effective to allow one to like, jump over over objects on the run, or to pass up a flight of stairs or a ramp for example, we need to allow movements in two directions at once. As of the code we have presently, this is not possible. And worse, because of the queing scheme I've employed we need a rewrite here, as what we have would only cause more problems as we go along. While I still accept the whole que scheme as a viable one for keeping the number of world updates per loop to be at a minimum, it will require a few changes;

1. The movement codes need to be changed. Specifically, since we must allow movement in two directions at once (like forward and up, or right and down) the movement codes should be bit mapped. What I mean is, forward=1, right=2, back=4, left=8, and so on. In this way, multiple directions can be added together, minus the obvious conflicts of moving both forward & backward at once and so on.

2. The tile map updates must be changed to reflect this kind of motion, such that object collisions can be detected both on the map and on the screen. This is the new array I mentioned above.

3. The queing system needs to allow dynamic updates to any particular moving object, such that both the change in action and its resulting destination can be processed by move() and arrivals(). This won't be a major problem I hope, but we'll see.

4. And of course, the player input will need to be extended to allow such things as jumping even with the object already moving, as well as detecting ramps or stairs and the like.

Basically, we have our work cut out for us, but we'll get there...

S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 11th Jun 2004 12:50
Okay, minor problem...
DBC at least doesn't understand the arithmetic logical AND. This means a new function to manage the bit mapping, bit of a bother but not impossible.

S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 14th Jun 2004 21:20
Hi again...

Bet you forgot about this one didn't you?

Well, I've been dinging around with the time in a variety of different ways, and came up with this mess which works somewhat. Haven't solved all the problems yet but at least it's doing something, though the jump code has big troubles. There's also an interesting side effect in that you can "run through" the sphere while it's rolling because it get removes from the world map during the process, another odd thing I have to correct.

But anyway, look it over and see if you can figure it out...
I've tried to comment most things, hope it's enough for you.
S.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 14th Jun 2004 21:38
Hehe... nope... i havent forgot about the project its just that that its kinda beyond my level of programming now so i break the code up and tweak parts of it and try to understand. at this level its hard to come up with something new to add to the full code.

ive added you to my msn to... but you always seem to be away

Dreaming of creating a highly advanced AI mind
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 15th Jun 2004 07:04
Well, the two biggest changes I've made is the movement que and the multiple object types. The object types are defined by the numbers we assign to them when we are building the map, and those vales determine how the object moves within the game world. That's the reason for all those case statements in the code. The movement que is just a new array that contains a list of all the moving objects at any one time, so things are put into the moving() array for the move() to proces them.

If you have any questions about anything, feel free to ask...
S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 15th Jun 2004 19:27
Hi again...

I was just, you know, dinging around the code and trying stuff, lighting, changing the colors of things, that sort of thing. Then I came up with the following replacement/modification to the seflmoving() code, and started playing around in the world;



Try it... your first task; Catch That Freaking Ball!
It's not as easy as it looks.

TTFN,
S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 16th Jun 2004 13:26
I am starting to wonder if I want to implement a lagging moving status map or a leading one, or even both for that matter. Currently I'm using a lagging map, and if you play with this code a little you'll see the problem it causes. However, building a leading map as well would be a bother, when the data should in the que array. This means checking for objects in the que however, which can be a trouble if the list gets too long because they are absolute coords. (While all other checking is done in grids.)

What do you think? Anyone got any suggstions?
S.

BTW: I've added a few more objects, even an annoying little "pet" of the player, and brightened up the colors a little...

Any truly great code should be indisguishable from magic.

Login to post a reply

Server time is: 2024-09-22 13:18:01
Your offset time is: 2024-09-22 13:18:01