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 / Help, I can't figure out 1 1/2 problems!

Author
Message
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 12th Feb 2004 22:27
OK, so I'm making a program, what I'm trying to do is listed at the bottom of the snippet. Sorry for not using gosub, but bear with me. Antways, there are two problems. First and most importantly, the object collision doesn't work! I can walk right through the AI! OMG. The second problem, which is more or less fixed, is that the sphere that you're in is halfway inside the matrix (the matrix cuts it in half). I solved this by moving the sphere up, but what the heck is going on? I need help here.
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 12th Feb 2004 23:17
OK, the object collision works now.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Feb 2004 00:10
When you create a sphere its origin is placed at its centre. So to make it 'sit' on the matrix you have to move the sphere up by the same distance as its radius

For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 13th Feb 2004 02:25
Well, the same thing happenned to cubes, I had to move them up too...oh well. In the inclosed code snippet, the only object collision that works is object 1 with object 2! All others don't work! Also, the bullet, which I have made moving very slowly and I also made very large, is not doing what I want it to! It is sitting there at 0,0,0 when it is supposed to be going to me! Also, it is not moving forward, either! Argh!
walaber
21
Years of Service
User Offline
Joined: 22nd Oct 2003
Location: Los Angeles, CA
Posted: 13th Feb 2004 13:06
two pieces of advice, two words each.

start slow.

keep trying.



Go Go Gadget DBPRO!

Athlon XP 2400+ || DDR-SDRAM 1GB || Nvidia Ti4200 AGP 8x 128MB
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 13th Feb 2004 21:39
Wow, that helps a lot. Can anyone actually help?
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 14th Feb 2004 00:26
Update, I got the object collision to work, and the "bullet" now fires, but when I shoot, except for the last shot in my magazine, if I hold Control, then the bullet floats in front of me until I release it. Also, about 1/4 of the time for cube bunkers and 2/3 of the time for the bad guy, the bullet just passes right through them! Also, the sound that is supposed to play when the bullet hits the cube only plays about half of the time, and for the left cube but not the right one, the sound gets cut off as it just begins! However, if I hold the Control key when I'm aiming at a cube so that the bullet floats in front of me, the sound plays until I let go of Control! Please take your time to respond, I really need help.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Feb 2004 01:21
I'd love to help, but to be honest, your code is getting pretty impenetrable despite being less than 100 lines.

Don't take this as a criticism, more as friendly advice from someone who had to learn all this the hard way ...

- Indent your code. It makes the logic easier to follow.

Bad:


Good:


Which is easier to read? Pick an indentation style that suits you and stick with it.

- Give your variables more meaningful names

You use 'magaz'. I would use 'MagazineCount' or something similar.

- Use functions or subroutines with meaningful names to break it up a little

You have this code buried in your main loop:


Replace it with a line 'gosub PlayerMovement', and then add the code to the bottom of your source file like so:


- Don't make your code more complex than it needs to be

You have this:


I converted it to this:


This has the same effect as your code, but is easier to read.

- Don't use "magic numbers"

You have an object number 3 - I have no idea from your code what that object represents. If instead of using '3' everywhere you used a variable like 'bullet' which had a value of 3 then I know exactly what that means from reading the code.

There are no hard rules here. For example, if I had code with a single matrix in, I might leave the number '1' in place.

The golden rule is 'Make your code easy for you to read'.

For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 14th Feb 2004 03:58
OK, I'll do that, but do you know what is wrong here?

About that, that wouldn't have the desired effect, would it? If I pressed space, that wouldn't reset rloat to 0 and dude to 1, would it? Or would it? Sorry, I'm new. And thanks for the help.
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 14th Feb 2004 04:17
OK, updated code included. However, the problems still are: the "bullet" very often goes right through other objects, the sounds that should play when you shoot the cubes usually don't, and if they do, there is only about a 2/5 chance that they will play all the way through, if you shoot from in front of the cubes (facing where you faced where you spawned) then the sound-interruption only happens to the cube on the left (object 3), and the bullet floats in front of you if you hold control, but only for the first four shots. Also, the ow.wav sound plays through the whole way without exception if you aim at a cube and hold control, so it seems that it is linked to angles, even though I linked it to object collision!
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 14th Feb 2004 04:18
Oh, and this is in DB Classic.
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 14th Feb 2004 18:57
Hey guys, isn't this forum for helping people instead of ignoring them?
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 15th Feb 2004 03:29
Really small update, PS, why isn't the soundplaying function working? It tells me something about an array.
EX on how I'm using it: if soundplaying(2)<=1> then var=0
<>those things on the left mean I sometimes include it, sometimes not.
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 15th Feb 2004 03:50 Edited at: 15th Feb 2004 03:53
It looks like your bullet is going 25 units per frame. If your collision boxes/spheres are smaller than that, it is entirely possible for your bullet to skip over the target. Drop the move object speed down and see what happens.
--
TAZ

[edit] Oh yeah, these forums are manned by volunteers and kind samaritans. They owe you nothing. Studying, patience and persistence are values that will carry you through.

sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 15th Feb 2004 04:36
Was I being demanding or something? And BTW, I don't want the bullet to move slooooooow, because that would be impossible to play except close range, but at close range, object collision fails without exception. ARGH!
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 15th Feb 2004 06:31 Edited at: 15th Feb 2004 06:34
Quote: "Hey guys, isn't this forum for helping people instead of ignoring them? "


What's your opinion of this statement? You might have been joking, but no one else can tell.

--------

Back to bullet speed. If you're wanting to move the bullet like that, you may end up needing to test it at intervals. Let's say your target is only five units wide. You could try incrementing and testing it five times at speed 5. Alternately, you can abandon bullet movement and use rays. Then you could have 'real' bullets that are effectively invisible, just muzzle flash and point of impact. [You could use laser pointers or ghosted lines for visual clues.]
--
TAZ


FYI, I'm a DBP user so I can only offer ideas for you to try.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Feb 2004 12:51
All good points for why the collions 'appears' to fail. Your bullet is simply jumping from one side of the obstacle to the other without actually having touched it. Another way to get your bullets to collide with scenery is to have a hidden object (maybe a box) that is the same length as the distance you are moving your bullet. Just place it behind the bullet so that it trails after and test this object for collision.

The reason for the bullet not being released until you hit control is simply that you are repositioning it whenever the control key is pressed, rather than disabling the action of that key for a while.

For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 15th Feb 2004 16:59
Thanks, I'll try the trailing box idea. And I'm not sure if I was clear enough, sorry if I wasn't, but except for the last bullet in the magazine, the bullets reposition and angle like they're supposed to, but only move forward when you release control. Thanks for your time.

P.S. zircher, what do you mean with rays? Sorry, I'm new.
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 16th Feb 2004 01:49
A ray is just a line heading in one direction. IanM's idea of a traling box with the bullet being like the head of a comet is pretty good. Minimal change to your code, you just need to orient the collision box at the bullet with a POINT OBJECT command. Figuring out the position of the box is easy. Just take the distance between the bullet's old position and its new position and average them.

rem bx,by,bz is the current bullet position
rem oldbx,oldby,oldbz is the last bullet position
position object bulletBoxID, (bx+oldbx)/2,(by+oldby)/2,(bz+oldbz)/2
point object bulletBoxID, bx,by,bz
--
TAZ

sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 16th Feb 2004 03:18
OK, that looks like it will really increase the chances of an object collision. Do you guys know why the object animation for guy.x isn't playing? (even when the bullet hits him and stops)
sponge008
20
Years of Service
User Offline
Joined: 8th Feb 2004
Location: MA, USA
Posted: 18th Feb 2004 23:19
OK, update. First of all, I can't figure out why the bullet and trailing cube aren't correctly repositioning. Second, you guys didn't really help me with the sound and firing problems! Please, I'm really desperate!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 19th Feb 2004 01:19
I think that your problems with the code are caused by the complexity of the code that you have.

The best advice I can give, knowing your older code is to *SIMPLIFY* your if statements. Keeping track of all those different values in different lines is a real pain. See the example conversion that I did earlier to one set of your if statements.

Also, bear in mind ...
- we don't know what your latest code looks like.
- even if we had your code, we don't have your media, which means we need to make changes to get it run at all.
- we don't have time to debug your code for you - we have enough buggy code of our own - You need to learn to debug.

For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
walaber
21
Years of Service
User Offline
Joined: 22nd Oct 2003
Location: Los Angeles, CA
Posted: 19th Feb 2004 08:40
indeed. personally I think you are moving too fast... by asking for help so much you give the impression that you aren't interested in why the code works, you just want ti to work now. Please don't be offened if I am wrong here.

My suggestion would be to simplify your code, and take everything step by step, making sure you COMPLETELY understand why and how everything works before adding things.

that's always worked for me.

Go Go Gadget DBPRO!

Athlon XP 2400+ || DDR-SDRAM 1GB || Nvidia GeForce 4 Ti4200 AGP 8x 128MB

Login to post a reply

Server time is: 2024-11-26 05:48:32
Your offset time is: 2024-11-26 05:48:32