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 / my cube wont move... help appreciated :)

Author
Message
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 01:25 Edited at: 6th Jun 2004 01:26
This is my move function... its supposed to move a object (for now the player cube) in the direction which was sorted out in the player input function.

However... it doesnt work .

I think it has something to do with the part when... you see the "if moving(object)=1" part? I got no end if there at line 106, i think it should be. But if ill add it, the editor says "command at of line".

Anyone knows what this is all about?

Thanks
Mizipzor

(also, full source included)



Dreaming of creating a highly advanced AI mind
soapyfish
21
Years of Service
User Offline
Joined: 24th Oct 2003
Location: Yorkshire, England
Posted: 6th Jun 2004 01:50
What is it your trying to do with this code. Move a cube depending on which arrow keys are pressed(although I admit it seems too complex for just that) Any chance of a bit more info. Thanks.

WAS DOING AN FPS BUT RAN AWAY AND STARTED ON MISSILE COMMAND INSTEAD.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 01:58
its supposed to move a object... now, the only thing to move is the temporary player character, a cube. But why its complex is that so i can move just about any entity ill add sooner with only the object number and direction provided.

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: 6th Jun 2004 02:13
I may not know much about the Dark Basic Editor yet, but it seems to me that an ENDIF is missing in that code. As for why the editor would complain about it being there though, and not complain about it not being there, I have no clue. Just simple logic says to nest them properly. Does it depend on where you place the endif given the couple of THENs in the last part? Have you tried putting the final endif at the point just before the function exits? I know that I would place it before the rem of where you check destination, but then again, if an object is not moving why check that?

The only other suggestion I can come with is, change the last two lines to be If...endif lines as well, to get rid of the THEN that might be confusing the editor. An interesting problem to be sure...

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 02:40
It was just a bug, i moved things around a little, it wouldnt work... so i moved them back... and then it worked!

Nothing has changed, the editor just let me have the endif ther now

thanks

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: 6th Jun 2004 03:03
Hahahaha!

Mizipnor,

Well, you might want to shoot yourself but I got it working too -- by a means that'll make you kick yourself.

First off, I had trouble getting all the code together. The source button only grabbed a part of it, then camupdate() was missing, then I had to grab the code snip and edit it to make it all work.

My version of the function is;


Now -- here comes the part for which you'll kick yourself..

Speed(1) = 1
Speed(2) = 1

I added those ... and it started moving!

I may be wrong, but I don't think you can use an AND word after a THEN, so I changed the order of the set moving flag as shown above. And is a logical function in most BASICs for combining flags and values used in an IF.

Have fun!
Sandra.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 03:03
i got that endif there now but still i cant get it to move... have tried a couple of things but i simply cant get it to work.

i have matrix walls and stuff now to, did that in between and then got back to my movement problem .

anyways, could someone please check out my source here? thats player_input function and move function then... the rest is just if you want to run it yourself

thanks again
Mizipzor

Dreaming of creating a highly advanced AI mind
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 03:10
hehe maybe you did beat to it ill try it out at once!

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: 6th Jun 2004 03:14
Well, after I got no errors and it appeared to display properly... it still wouldn't move for me, I started looking at the defines and relized you'd never set a speed value, so at a speed of zero nothing is ever going to move.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 03:20
Well... a question then i got those arrays to be able to handle all the players... for now its only two. How do i set a value to all the elements in an array? its called array right? at least in c++

Another thing... for some wacky reason it doesnt take input anymore! I have that little number up in the left to state the direction... it stays at a sturdy zero. Any idea whats wrong? I dont know what things ive messed up now, to be honest im way to tired to try to program. Its 01:20 am here :/... programming should be this fun

Well thanks again...
Mizipzor

(included the scource... _again_ )

Dreaming of creating a highly advanced AI mind
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 03:21
the rest of the code is below:

(is there a maximun lines to include here?)

Dreaming of creating a highly advanced AI mind
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 03:25
what the... ****

this forum doesnt like me!

It cuts out half the move func and the entire cam func /me wonders if this works:



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: 6th Jun 2004 03:31
Uh...

I don't know if there is a maximum line limit for posting or not, but I know that the source button after each post is only giving me a part of the program. Each one seems to cut off at;

rem if its moving....
if moving(object)=1
rem up
if goal_z(object)>

and that's all I get.

As for setting array values, I usually do it the brute force way;

For x = 1 to maxplayers
speed(x) = 1
next x

And so on. While this does not matter when initializing it can be a bother if it's in a main loop or anything like that.


As for the input stuff... hmm. I'm not having that problem. In fact I was going to suggest that you change the input code because the current input is based upon whether or not an object has stopped moving, meaning it continually moves even when a key is released until a different key is pressed.

And I wanted to add the suggestion of changing your signs in the Movement section, to make the motion more intuitive. (ie; + to 1 and - to +)

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: 6th Jun 2004 03:33
Okay, let me see if this works....

this is my version as of right now.

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: 6th Jun 2004 03:36
Nope.. it cuts if off as well.

There is clearly a posting size limit here, which is making this harder than it needs to be. But oh well, I understand that reason for it.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 03:36
Thanks Sandra, youve been of great help! I owe you one (hundred)

I look into that tomorrow, as I said, Im way to tired now... anyways

Thanks again!
Mizi
/me snores

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: 6th Jun 2004 03:37
Okay, part two of mine....

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: 6th Jun 2004 03:39
Darn it.. it cut if off too... there must be something in the code that's being recognized as a command.

Tell ya what, I'll email it to you...

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 03:41
can it possibly be the same thing that made it impossible to have endif that now makes the code cutoff?

if you ask, yes im _on my way_ to the bed i, brushing my teeth in front of my computer

Its hard letting something fun up

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: 6th Jun 2004 03:43
one more try.


Since it seems to keep stopping at the same point I'm trying to add extra spaces around the stoppage

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 03:44
goodie... it worked now

the cam func and the entire move func is there...

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: 6th Jun 2004 03:45
No, I think it's something the browser is seeing as a command for a graphic or something... which it never gets out of. So the text disappears.

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: 6th Jun 2004 03:49
Yup, it's confirmed.. it's my browser. For some reason, when it hits that if goal_z(object) line it stops all output. If I look at the source of page (which I should have done earlier) I can read the full text correctly.

Weird.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 03:51
Darn!

Now i get that "command out of place" when im trying to put endif there... could you mail me your entire source? Mizipzor@hotmail.com, Ill send mine back, maybe it isnt fo much use but just for comparing or... whatever

Dreaming of creating a highly advanced AI mind
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 03:58 Edited at: 6th Jun 2004 03:59
Well... i didnt care about that endif it works now... kinda...

The thing is I want it to move pretty strictly by the matrix tiles, as i want it to be kinda tilebased. Any idea how to fix this?

For me at least, it just moves around pretty freely.. not good

Dreaming of creating a highly advanced AI mind
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 04:03
Im going to bed now... for real if you wonder why I did stop posting here... Ill return in a few hours when ive got enough sleep to keep my brain rolling hehe...

Thanks again! bye for now
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: 6th Jun 2004 04:49
Hi again....

I was playing with your code some more and wanted to retract a comment made earlier, specifically about "reversing the + and - signs in the movement section. (The code I sent has the signs reversed, when it should be the way you posted them.) i.e.;



Reason is, I wasn't sure which object was actually moving. Once I took the update_cam() function out of the main loop so the view didn't follow the moving object, it made more sense to me...

Now, as to the input stuff I mentioned earlier, here's the correction I found that works;



By just reseting the direction to zero if the object has reached its "planned destination" via the move() function, when the player lets up on a key the object will stop at the next point. Since you have a preset movement size defined in the move() operation, it should form a "snap to grid" as well.

I'm not sure if this would be "by matrix tiles" or not given the way you have asked your question, but it might. Once you awake maybe we can continue this discussion and find out.

Sleep well and good luck,
Sandra.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 13:15 Edited at: 6th Jun 2004 13:16
Hi again, Im alive and kicking

Problem remains the same... the cube doesnt move... for me

Ive changed a couple of things, mainly in the player_input function but thats clearly commented , also i have more in the print_status function.

Heres my code snipper: (attaching source isnt that effective as weve found out )


Play around and see what you can find out... Ive been up for about an hour now and now its time for breakfast... see ya soon!

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: 6th Jun 2004 18:49
Mizipnor,

Hmm... interesting that yours won't move and I can't stop mine from moving! What I mean is, I've been up most of the night playing around the sample I have here and discovered an odd quirck in my version of the code -- it allows me to go DIAGONALLY!

What I did was; change the Goal distance to 100 plus former postion, then press a few keys. Turns out, I can have the cube head for North and then press East, where upon it moves North-East for a while, then turns directly East. Theoretically, that's not possible.

The only thing that I can come up with regarding my version of the compiler is that the truth flag of "moving(object)=0" is being preserved and carried to Move() whenever the key is pressed, which updates the destination all of the time. This makes any snap-to-grid impossible.

This is so very odd... I can't figure out why we're getting such different results.

Code follows;


Oh yes... I also took out the "direction" parameter for Move(), since your code wasn't using it anyway.

Let me know what happens when you try this one...
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: 6th Jun 2004 19:31
Okay....

First the errors I encountered in my DBC version;

1. All Dims had a space between the variable name and the size of the array defined.
ie; "dim speed (maxplayers)" not "dim speed(maxplayers)"
2. Had a nesting error on line 199m finding;
3. The first two If's of the "moving(object)=1" section of move() didn't have endif's
4. had to add several spaces in conditions for sanity.
5. Had to change Destination if..then's to IF...ENDIF to get rid of nesting error claim

At this point the cube would not move, so I did the following;

6. Added "moving(object)=1" after Goal Calculation lines.
7. added "direction(object)=0" to destination section
8. Removed "if direction(object) > 0 then moving(object)=1" line in Input()
9. Removed IF condition from move() line in Input().

At which point, the thing moved, but STILL has the problem I mentioned before; ie, if you hold the key down while moving, the goal destination does NOT line up to even values of ten.



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: 6th Jun 2004 19:36
Oh yes... I also took out that direction parameter from Move() again... since we're using the global array of Direction() for the function.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 19:47
Did try your codes, the one posted 11:49 is an old version of the gamecode... didnt work anyway so... but the one you posted 12:31 worked just fine! My cube moves now... only thing is that my "snap to grid" style is far from working .

Ill read the code in more detail now and look up whatever was changed.

Btw, the reason i want this "snap to grid" is that I planned to make this game something about pushing other cubes around maybe a puzzle style. But since im so new I for now only try to make the game system works hehe .

Dreaming of creating a highly advanced AI mind
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 19:55
Hahaha... i want to kick myself again

I figured it all out!

Down in the move function where we check if goal_x and goal_z was the same as its position, i.e. it is where it was going to. We set the move(object)=0 and direction(object)=0...

The problem was, we set it back if either the goal_x or goal_z criteria was met! In this code we only set move and direction to 0 if BOTH goal_x and goal_z is the same as the cubes current position.

I dance in joy now hehe... it works... well att a first glance at least... soon i found out something else i guess



Also, I shrunk the cube slightly, thinks it looks better ^^

Anyways, thanks thanks and thanks again

Any ideas on what to implent now when we have a controll system?

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: 6th Jun 2004 20:37
Well, I noticed an extra "endif" in the stuff I posted... when also trying to figure out this snap to grid operation. Here's the correction;



Now, as for the snap to grid; Well, I'm still dinging with that one. And yes, I know the game of pushing objects around, though I forget its exact name. One version I saw years ago was called "Bolo Adventures" (1, 2 & 3) but another version I saw was called something else and in a Forth newsgroup. Not even sure which is the correct name really, but have seen it before....

And you're right about the AND I believe, that might just solve this silly snap problem. (silly things!)

I have a similar sort of problem in my project, except that I used matrix arrays to restrict movement.

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: 6th Jun 2004 20:45
Yep! That AND did solve the problem, even the diagonal movement!

Grrr.... makes so mad at myself.

When I first proposed the OR it was just to simplify the code you had originally, didn't even think about what it was doing. Whew. Myopia big time!

S.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 20:51
I also saw that little extra endif, edited it out... just a little typo feel silly if I mention those small things...

However, I have quite a working "snap to grid" system now... except one thing...

It looks good from one angle but i decided i wanted to see the scene from another angle so i changed the camera func. The reason is another bug ive found , but i want to solve this out first.

If youre willing to help me again hehe, try in the main loop to pass the argument 2 to the update_cam func. I have camvariants 1 and 2.

Also Ive added and edited a small amount of stuff that bothered me. Among those that the goal_z never was an equal ten (sorry if im saying it wrong, i dont know how to say it... the number cant be divided by ten whitout getting fractions) it was aldways 5 added to it. Thats fixed.

Anyways, heres the code as mine is now: (its a new project in case i want something back from the old one, the backup )



Cheers
Mizipzor

Dreaming of creating a highly advanced AI mind
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 6th Jun 2004 21:20
LOL... guess what was wrong

The reason to why the cube didnt seem to be snapped to the grid in the other camangle was that it all along have been floatin 5 units above it .

Hehe, smashed that bug to... heres the fixed 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: 7th Jun 2004 04:15
Hmm...

Not sure what you mean by the camera function stuff, but then I'm still asleep as I just crawled out of bed. Was working so much I completely lost track of time, and simply forgot to go to bed.

I'll look it over and get back to you.
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: 7th Jun 2004 05:12
Wow!

I must say I like the camera variant, it makes for a very nice viewing option! I did have a little problem getting it to run though, the first being I have classic that doesn't know the keyword GLOBAL. But that was easy to fix, "dim camvariant(1)"

Second, I still had to add in that second ENDIF at the bottom of the move() function, for it complained of a nesting error. But hey, it ran and looks great!!!

Now we just gotta come up with something to use this code....
S.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 7th Jun 2004 09:42
So typical me... struggle my ass off with the code for the game engine and I dont even know what to use it for yet .

But why dont team up? We could discuss every game aspect and code error throughout the project. We seem pretty much on the same level. The only thing, as you said, is that you have DB Classic but that shouldnt be to hard to convert between .

Just wonder how long the moderators will let us clutter up the board with this... 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: 7th Jun 2004 14:11
Well I did try to send you a email confirmation of subject "AI" from the misc. topics thread, but I guess you never received it for some reason. When I tried to send the code snip I mentioed in this thread, I got a notice saying "unacceptable user" or something like that from the mail client. (Don't know why it said that, but it did says it sent the letter on a second try.)

Anyway, maybe we could start a new thread if need be, now that we this part of it working at least. I suppose the next thing is keeping the cube inside the world.

S.

Any truly great code should be indisguishable from magic.
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 7th Jun 2004 16:03
Yeah... Ive been thinking of that... sort of collision detection. One way, i thought, would be to use pick object and if there wasnt any cube there then the move could be done. But pick object uses the screen coordinates and not the worlds coordinates. Another way, i havent figured out how it works exactly, but if we could read from those DATA statements i had to build the level and see if there is a "1" in the tile were going to. If there is... no move

However, Ill start a new thread and call it "Subtanks project" and state that there is something that been growing through this discussion and that everyone is free to join in.

See ya there
Cheers
Mizipzor

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 16:15
New thread up

Post post post... Im feeling lonely

Dreaming of creating a highly advanced AI mind

Login to post a reply

Server time is: 2024-11-26 20:25:49
Your offset time is: 2024-11-26 20:25:49