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.

DarkBASIC Discussion / Adding multiple items on the radar.

Author
Message
Lover of games
21
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 23rd Aug 2006 18:53
I've managed to add an item to the radar, that was easy. I made an Array called Healthpacks(100)
Healthpacks(1)=healthpackname.x

here's some code.



hope this helps you in helping me.

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Kentaree
23
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 23rd Aug 2006 18:55
Uhm, it helps if you specify the problem aswell

Lover of games
21
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 23rd Aug 2006 19:17
Ah, sorry. main thing is that the objects aren't appearing on the radar. when i tried to put another circle for only on object on the radar it worked. but i can't figure out how to make the healthpacks appear. I could make a circle for each on seprately and load them as different numbers.......but that's alot to write.

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 25th Aug 2006 04:42
Check out this excerp from the Tutorial "Monster Hunt":

http://developer.thegamecreators.com/?f=t01/3d_tutorial_23

This particular section describes creating a HUD with a radar.

Enjoy your day.
Lover of games
21
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 25th Aug 2006 23:45
This is going to sound mean, i hope not, but i already know how to add 1 item to it, i've added a monster and put a green circle. I tried to add multiple circles for healthpacks. (you know how some games have squares or something to show where multiple items are? If you'd like i could paste the whole game code from Monster hunt because i'm using that very source code. So the whole radar tutorial from monster hunt tutorial doesn't help. Sorry. I'll keep on trying to figure it out. right now i'm working on added the ability to rotate the camera while having mouse look like in Half life.

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 26th Aug 2006 01:43 Edited at: 26th Aug 2006 07:17
Doesn't sound mean at all.

couple of things:



From what I can tell, there is no reference to the position of any objects in this block of code. The way it's set up, you're drawing 71*71 circles in the same spot. DRZ# is always going to equal 50 because the last value you have z defined as is 0. X only changes once every 71 iterations. I'm not sure what you were actually going for, but I think you were trying to get the object positions and draw them on the bitmap. See my code at the end.

Another problem I suspect you would run into is the z component logic when you are drawing the circles. Remember, a bitmap has values in w x h from 0 and up. There can't be a negetive value - so don't try to manipulate the positions on the circle by just trying to negate z. To change bits to on or off in a bit map, one would use boolean logic: AND, OR, XOR blah blah blah... but luckily, DarkBASIC has Mirror Bitmap and Flip Bitmap commands to make this easy. Just flip the bitmap and the orientation of the radar should be fine. If you want the radar to rotate as your character moves around in the maze, then rotate the radar object in sync with the character.

Here's some bare bones code [Edit] based on the radar concept from the Monster Hunt Tutorial:


Enjoy your day.
Lover of games
21
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 26th Aug 2006 03:05
Unfortunatly when i tried to apply your code to Alien Hunter it didn't work. ur example worked though so i'm going try to see how i can make it work on mine. thank you.

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 26th Aug 2006 07:26
If looking at the code isn't clear, let me know and I'll write up a detailed explanation.

Enjoy your day.
Lover of games
21
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 27th Aug 2006 04:34
Well, I tried to do it like you did but i guess u need to do it differently in Alien hunter. I followed the example as u showed me, maybe if you game me a better explnation, it might help. thanks for far

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 27th Aug 2006 16:04
What is Alien Hunter? Is it the same tutorial as Monster Hunt?

Enjoy your day.
Lover of games
21
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 27th Aug 2006 18:11
yes, different name, same game

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th Aug 2006 03:44 Edited at: 29th Aug 2006 03:48
Ok, I'll try and explain how the radar works.

In Monster Hunt, the radar is like a mini picture of the whole environment of the game. What I mean by that is, the radar is sized to encompass the entire world in one view. The radar doesn't scroll left or right, up or down. Its one view represents the whole world at once.

The radar could be coded to have only a small view, say 50 units in any direction around the player. Then as the player moves, the radar would scroll to reveal more of the "map." We'll stick to how monster hunt has it set up, to display the whole map at once.

Now that we've decided on the view size, we have to decide what we want displayed. When we decided that, we are going to draw shapes on a bitmap offscreen to represent the display. Then, we are going to capture the drawn bitmap as an image with the GET IMAGE command and paste that image as a texture onto a flat 3d object called a Plain in DarkBASIC. In the original Monster Hunt, a bitmap is loaded first that represents the radar's background. Then, only the Player and the Monster are drawn on the radar.



These are the commands that load the background radar screen to bitmap screen 2 and create a 50 x 50 bitmap on bitmap screen 1. The 50 x 50 dimensions are important to note because this is the size we have to represent our entire world map on the radar as.

Later in the main loop we see:



This first line copies bitmap 2 to bitmap 1 (the radar background onto the bitmap we will draw our circles on).

Next it sets the bitmap we want to draw on (bitmap 1). Then we change the color to blue. The variables PRX# and PRZ# represent the player x and z coordinates for the radar. These coordinates are pulled out of the player's X and Z position in the 3d world. We have to take these coordinates and apply them to our 2d radar so we can draw a circle in the right spot. Since we know the matrix size in 10000, we divide 10000/200 to scale our coordinates down to 50 to fit on our radar bitmap (remember when I said 50 x 50 would be important?). I mentioned in a previous post that the Flip Bitmap command could be used to orient that z position on the radar so it isn't upside down, well, Monster Hunt handles this with

PRZ#=50-(Z#/200)

Because the height of our bitmap goes from the top 0 to the bottom 50, and z in our 3d world goes the opposite from this, the 50-(z#/200) will ensure that the z coordinates from the 3d world will be positioned correctly on the 2d radar map.

Once we have the coordinates of our player object and they are converted to radar size, we draw a circle at the PRX# and PRZ# coordinates. We then change the ink color to red, and do the same exact process for the Monster (MRX# and MRZ#).

I added a line to the original routine :



This line rotates the radar image to maintain the radar orientation with the world.

On to The Demo Code I wrote earlier:



This bit of code is an example of how to have multiple items showing up on the radar at once (your original question). I used the same principles as Monster Hunt, but did a little adaptation for demo purposes.

I wanted to make things easier on myself, so I made a matrix that was 200 x 200 and I decided to make my radar bitmap 200 x 200 also so I didn't have to do any conversions for size when I bring over the coordinates of my objects.

So the position of my objects (spheres) would change every time the program was run, I used a random value for my x and z positions after I created the objects. I did this all in one loop:



Now, the rest of the code uses the same method as Monster Hunt to set up the radar display; I draw an offscreen bitmap, I point to the bitmap, I create a loop to get all of my spheres x and z, then I draw the circles on the bitmap at the locations of x and z. I use the Flip Bitmap command to turn everything rightside up (remember, the z on the bitmap will be top 0 to bottom 200 which is opposite from my 3d world).

You can apply all this information to modify Alien Hunter.

You wanted to add health packs. Ok, let's say there are ten health packs. First thing to do would be to decide on a range of object numbers that will be health packs. For this example, we'll reserve 1000 to 1009 specifically. So from now on, whenever there is an object with a number from 1000 to 1009, we know that it is a health pack.

Next, we want to either load an .x object for the health pack or we will create it out of a primative. For this example, we'll just create cubes.

We will create a subroutine (procedure) to handle the creation of our helath packs. We want to call this routine from within the PlacePlayer routine. You don't have to do it this way, but I am, because I want everything to be reset every time a new battle begins, and the PlacePlayer routine happens at the start of every battle.

Here is the subroutine:



This code is just a variation of my demo code. I just had to add a reference to the collision routine that is setup inside Monster Hunt so the health packs don't appear in the middle of the pillars. I just did it the same way it's done in the PlacePlayer routine. Once DecoCollide is called and the HPX# HPZ# and HPY# are ok, then we can position the object.

This routine also does the initial creation of all the health packs. There are 2 checks to see whether the healthpack exists or not. If it doesn't exist (it's either being created for the first time, or maybe it disappears after the player uses it), it will be created. If it does exist, it will just be repositioned.

Now the only thing to do is to draw the health packs on the radar:



That small section in the middle does it. We just set up a loop to cycle through the health packs and draw the circles just like we did for the Player and the Monster.

Here's the complete modified Monster Hunt code. You should already have all of the media:



Enjoy your day.
Lover of games
21
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 29th Aug 2006 05:44
Thanks, that worked. Now.......about collision with the health packs..Would I use the same code that's in the DecoCollide() function and change it so if the player health is less then 100 add 10 points to the health then hide the healthpack that was colided with then delete the circle of that pack off the radar? would u use Arrays for that? P.S. sorry if i'm being annoying.

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th Aug 2006 10:44
Actually, you would have to set up different collision detection for the health packs. Reasons being:

1. The code I supplied does create healthpacks at random locations, but it doesn't check if two health packs appear at the same spot. You'll have to detect for that somewhere in the PlaceHealthPacks: subroutine.

2. The healthpacks appear at random locations so DecoCollision won't necessarily be applicable for player, healthpack collisions.

I recommend instead of hiding the health packs on collision with the player, that you delete the particular health pack altogether. That should automatically remove it from the radar and save you some cpu processing; though you will have to test for the absence of a missing object so you do not return an error whenever redrawing the radar. I designed PlaceHealthPacks with that in mind. When the routine is run, it will create any missing healthpacks and then shuffle all of them around.

Expand on this for the radar:



In the loop add a test for Object Exist(hp). If Object Exist(hp) <> 1 then don't draw anything. I'll let you work out the details. If you get too stumped, just say so.

For your Health Pack collision routine, you essentially want to check the position of the health packs against the position of the player. You could use DBC's collision detection for that. Set the player and set the health packs to box collision. When they hit, you want to get the object number of the health pack returned. Then you want to delete the health pack and add 10 to your player's health.

Tip: In the main loop, check for the collision and if collision <> 0, check the health and see if it's less than the maximum - if so go to a subroutine or function that will delete the healthpack and add the 10 points to health. You might want a health limit check here so it never goes above the maximum. If you use a function, you could pass the object number of the health pack to the function from the main loop when the collision occurs. If health is at maximum already, you don't want to use the health pack, so the "usehealthpack" routine should be skipped.

I'm not sure what you want to do with the arrays so I don't know how to answer that.

Enjoy your day.
Lover of games
21
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 4th Sep 2006 16:06
I've tried to set up box collision, didn't go so well.......

Here's what I did:

made a collision box for the camera


then Put this in the main loop:



Then made the HP into:



If u could help me with this, then next time I would know what to do when I do a similar game. Thanks, mate.

(Note: Not really australian)

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Sep 2006 01:16
Hey there L O G,

It can be tough to get collision right!

Ok, here's what I did, though you may miss out on the satisfaction of figuring it out, read on.

I kept things simple. I didn't want to rewrite a bunch of the code, so I just stuck stuff in that makes it all work. First, camera collision. I was going to use the gun barrel, then decided to just make a cube that the camera "sits on" that adjusts to ground height so it will always be on the same plane as the health packs. I made it a little bigger than the health packs so I'm sure it will hit. Then I hide it so you don't have to see it poking out around the sides. I put the code near the top after the Make Gun bit. Instead of making a collision box, I just set object collision to boxes 999 which sets the dimensions automatically.



Then in the main loop, I want to position the invisible box wherever the camera goes, and I want it relative to ground height:



Just before I make the radar, I want to check for the collision with the health packs.



This requires a change to the PlaceHealthPacks procedure, and the creation of a new procedure called UseHealthPack. Like I wrote in my previous post (more by implication I think), we have to make the health packs collision detectable so in the loop in the PlaceHealthPacks procedure I include set object collision to boxes hp. I also include a Repeat Until to compare the position of each health pack so that it doesn't occupy the space of one already placed (so they aren't on top of each other). Here's the modified PlaceHealthPacks:



This can be compressed to smaller code with a little less redundance, but it suffices for the example - and this routine is only run once between player lives.

The new procedure UseHealthPack checks to see if the player is injured (phealth < 100) and if so, use the health pack they are colliding with. I thought it would be interesting to use CASE SELECT to assign different values to different health packs! CASE SELECT can cut down on a lot of IF THENS depending on what you want to do. hpcollide is set in the main loop when the camera box collides with a health pack. The number of the health pack is returned in hpcollide, that is how we know which case to select and assign a value to phealth.

If the health pack is used, it is deleted. If you delete the health pack, you'll save some processing power. If you hide it, it will still try to detect collision. I noticed a marked performance hit when I added collision to Monster Hunt. Anyway, If the player is at full health, a health pack isn't used. Here's the new procedure:



Now that we have a routine that deletes a used health pack, we have to remove it from the radar. This is easily accomplished by checking if the object exists and modifying my original radar code.



Two things left to do: We have to add the variable phealth to the PlacePlayer routine so health is reset everytime the player is respawned, and we have to modify MonsterShootBullet to injure the player.

Here's the entire program:



Enjoy your day.
Lover of games
21
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 6th Sep 2006 05:30
It works, thanks. Just gotta fix it up a bit Now........to add the ability to let the AI go for a Healthpack when the MHealth is down One more thing: What kind of format was the monster exported as? Cause when I opened it in wordpad, it wasn't like the usual .X file. it was all weird and stuff. Thanks again for this code.

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 6th Sep 2006 06:31
There's a header at the top of the files that identify it:

xof 0302bin 0032

The 0302bin means that it is a binary file. I haven't worked on creating or manipulating the xof binary format. I know it follows the same principals as the ascii format (the ones you can read with note pad), but it's binary to be a smaller size and to process faster.

Enjoy your day.
Lover of games
21
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 6th Sep 2006 10:59
I guess i could save it to a mesh file cause i'd like to edit it in max.

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Scraggle
Moderator
22
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 9th Sep 2006 09:52 Edited at: 9th Sep 2006 09:54
This:
Quote: "t=200
for x = 70 to 0
for z = 70 to 0
load object healthpacks$(1),t
HY# = get ground height(1,x*1000,y*1000)
position object T,rnd(x*1000),HY#+10,rnd(z*1000)
next z
next x
"

Will not work at all! The reason is:
If you have a FOR...NEXT loop that decrements then you must have a negative step value after it.

Try this to see what I mean:



Login to post a reply

Server time is: 2026-07-07 12:27:12
Your offset time is: 2026-07-07 12:27:12