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 / Ladders, Elevators, Escalators.

Author
Message
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 10th May 2011 03:33
I am trying to complete my final game for my Video Game Development class and need a bit of help. It seems ladders would be the easiest to do thought still beyond my capability. Could you kind people please tell me the basics of creating Ladders, Elevators, and Escalators?
Sinani201
16
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 10th May 2011 08:09 Edited at: 10th May 2011 08:12
I'm a bit confused as to what you're trying to do. Are you trying to draw an escalator in 2D/3D? Or something else?

Look at your sig. Now look at mine. Now look at your sig. Now look at mine. Now look at your sig. Now BACK TO MINE.
Sinani201
16
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 10th May 2011 08:10 Edited at: 10th May 2011 08:11
Sorry, double post.

Look at your sig. Now look at mine. Now look at your sig. Now look at mine. Now look at your sig. Now BACK TO MINE.
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 10th May 2011 23:15
Trying to make a usable elevator or escalator or ladder (3d)
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 11th May 2011 05:19
Well it depends on how your collision/motion system works.

My suggestion is this (though its pseudocode since I just made it up). Also, keep in mind, I like math, and this will involve a decent amount of vector math. I'll try to explain it, but if you don't get it, drink the kool aid first and see if it works (theoretically it SHOULD work, but I'm making this up off the top of my head). I will be using wedge notation, where a vector is denoted by <X,Y,Z>. Its just like a coordinate, but rather than storing points, they are difference values, so a vector from (5,3,2) to (7,9,1) would be <2,6,-1>.

Think of those areas as a tunnel from the start to the end. When you enter that tunnel (start the elevator, get on the escalator, grab the ladder, etc) a flag is set that restricts your motion (not as important in the elevator but bear with me) to only forwards and backwards (which would require looking up the elevator to move up, but that's how it usually works anyway).

Now for the math. When you move, you are essentially moving along a vector from Point 1 to Point 2. A vector equation can look like:

<V>=<X2-X1,Y2-Y1,Z2-Z1>

You will want to also construct a vector between the start of the "tunnel" and the end (beginning of ladder and end of ladder) then convert it into what's known as a unit vector. A unit vector is a vector with a length of 1 and goes in some direction (in this case, from the beginning of the ladder to the end). To do that, the vector is:

<TX2-TX1,TY2-TY1,TZ2-TZ1>

To turn it into a unit vector you simply divide by the magnitude of the vector (you might want to save these distances somewhere, I hear the square root command is a bit slow when you have to do it a bunch). So the Tunnel Vector, <T> is:

MT=Sqrt((TX2-TX1)^2+(TY2-TY1)^2+(TZ2-TZ1)^2)
<T>=<(TX2-TX1)/MT,(TY2-TY1)/MT,(TZ2-TZ1)/MT>

Now, we are going to compute the dot product of the Tunnel Vector, <T> (Instead of all that stuff above, I will shorten it to: <T>=<Tx,Ty,Tz>, and the Movement Vector, <V>:

<V>*<T>=(X2-X1)(Tx)+(Y2-Y1)(Ty)+(Z2-Z1)(Tz)

What this does is it will find the component of the movement vector along the unit vector (its a mouthful, so if you want a clarification, I can try).

Now what? Now we want to move the player from his position, (X1,Y1,Z1), a distance <V>*<T> along the tunnel. To do this, we will multiply the distance by the unit vector.

D=<V>*<T> As computed above
<M>=<D*Tx,D*Ty,D*Tz>=<Mx,My,Mz>

Then we position the player at the new point:

POSITION OBJECT PlayerNumber,X1+Mx,Y1+My,Z1+Mz

And there you have it!

An escalator uses some similar stuff, but the difference is that you will take your Movement Vector, <V>, and add the speed of the escalator along the tunnel (once again, this can be computed once and it is the movement speed multiplied by the unit vector of the tunnel, <T>

Elevators are easier than both in that you are only moving up and down. In every iteration, just move the elevator up its movement speed and the player too. If you have a weird elevator that goes in odd directions you will need to use the same math we just did, but I don't imagine this is something you are doing.

Now, what doesn't make sense?

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 11th May 2011 23:16
Hi there.
Well ... when we all start with something new, it is better a practical an simple example in orther not banging your head against a brick wall.

What I will do, is for example a square surface (object box 10,1,10) for the elevator, and program condition by collision, or if we are into an area or whatever...in this example I will decide collision method.

The elevator is object 1
Player is object 2

if object 2 collide with object 1, then elevator start going up then we just have to position object 1 in x,elevator position y,z


if object collision(1,2)>0
move object up 1,1
position object 2,object position x(2),object position y(1),object position z(2)


This is the idea...you can decide how height the elevator must go up...or down.

If you want, I will make a tuto for you.

Cheers.

I'm not a grumpy grandpa
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 12th May 2011 01:07
Here's another suggestion to throw into the mix:

Glue the player object to a limb that is the elevator or escalator. Use position object <player>,x,y,z to create the offset if you want to move the player around while the elevator or escalator are running.

The pseudo code looks like this



Enjoy your day.
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 12th May 2011 02:14
:o Yeah it's official: Video Game Development will not be my profession. But for now I have to finish the task at hand. Thank you for these suggestions and Chafari I would love a tutorial. Thanks.
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 12th May 2011 09:10
Quote: " Yeah it's official: Video Game Development will not be my profession"


Don't be discouraged, programming is hard enough as it is. Programming games is even harder. I've been programming in DarkBASIC for nearly 7 years and I haven't made a full game yet (I keep telling myself I can, then I get bored and switch to a new project).

Also, I would suggest learning in 2D, rather than 3D. The 3D commands have a nicer learning curve at first, but you stagnate really quickly. With 2D its a little slower getting started, but once you start picking up on the tricks, you advance relatively quickly. Most are directly applicable to 3D games as well.

That's why we (the forums) are here though, to answer your questions and help you out.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 12th May 2011 22:47
Hi there.

@DarkbasicBegin
I have been long time with the Darkbasic Pro, which has much more commands, and I had to adapt this piece of code to Darckbasic clasic.

This code can be much improved, but it will show an idea of how to go up & down in elevators.With this small example, I don`t mean to indicate that it is the ideal way to do it, because surely there will be more ways to do it.




Here`s an example of how to go up & down of ladders. It´s an example for Darkbasic clasic....in Darkbasic Pro, there is better ways to get it, but in Dbpro, there is the command INTERSEC OBJECT or sparky´s plug-in for collision that in Darkbasic clasic we have not ( I think nowaday there´s a plug-in as well for clasic).

I hope it can help you to understand a bit more about collision.



I`v got a code for going up & down a scalator, but I have to convert it to Darkbasic clasic...most of my codes are made in Dbpro...if you want it, just let me know.

Cheers.

I'm not a grumpy grandpa
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 13th May 2011 00:45
BN2 Productions. I really wish I could work with 2D but I probably would fail my project :p Maybe I can just squeeze through this final and next year become familiar with coding during my web game design class. Thanks for the encouragement!


Chafari. That's a really great elevator! Thanks so much. I had a little trouble understanding how the slanted ramp could be a ladder though. Anyways with the elevator I won't need an escalator or ladder! It's great! Thanks again.


Dark Basic Community. It's probably simple but how would I go about making it so that there was no elevator until all the level enemies were destroyed. At the top of the elevator I want a portal that brings me to the next level. Thoughts? I don't mean to give you any more work than I'm sure you already have but the game I'm working on is a FPS and right now it's just a gun sitting on the middle of my screen. How would I attach hands to it, and how would I add crosshairs.
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 13th May 2011 01:45
For the conditional elevator, what I would do is either disable the elevator until all enemies are dead, or keep the doors closed until then. Once all enemies are dead (keep track of the alive enemies and when it hits 0), open the door.

As for the gun, a way I saw a real game do it was:

On the gun model, include 2 limbs (they don't have a real shape, they are more of markers). You then have 2 different hand models. Place them at the limb locations (that way for different guns, you change where the hands are supposed to attach and the program will assemble it all).

Easiest way though: just place the hands on every gun model.

You could also drop it down to the corner and hide the hands off screen.


For crosshairs:

Make the image (make sure that the background/invisible color is black). Load it. Make a plane (MAKE OBJECT PLANE) with the width and height of the image. Texture the plane with the image and use SET OBJECT to turn the cull on (or off, whichever makes the black parts disappear) and set the Lighting flag to 0 (this should disable it's sensitivity to lighting in the scene).

Then, place the object at a fixed distance away from the player and use DISABLE OBJECT ZDEPTH to make sure that it is rendered over other objects (so if you get close to something it won't disappear into it).

Make sense?

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 13th May 2011 02:07
Quote: "For the conditional elevator, what I would do is either disable the elevator until all enemies are dead, or keep the doors closed until then"


Yeah!! this is problably the best idea



Cheers.

I'm not a grumpy grandpa
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 13th May 2011 03:52 Edited at: 13th May 2011 05:04
Chafari. I added your
for i= 1 to 2
if object collision(3,i) then y#=object position y(i)
next i
and
`gravity ... if we are not over one object, we fall down until we touch the floor
if object collision(3,0)=0 then y#=y#-2
position object 3,x,y#+2.5,z
And edited it to fit my numbers, but it won't leave the ground to get on the elevator. Could this be caused by my matrix for a floor? And also since all I am is a gun really since it's an fps when i changed it so that the gun's y value would change it suddenly just didn't show up when I started the game.

Anyone. I have a door that will open and close but I've never worked with anything like that. Also if it's a perfectly square matrix where would I put the door and elevator so that the door would block the entire entrance? Hopefully my final question. How could I add small patches of water here and there. Water = Extra credit
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 13th May 2011 05:17
Darn that whole part is gonna have to be different since it's a first person shooter. So instead of

what would it be?
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 13th May 2011 12:31
I apply gravity if there´s not collision at all with the player....in your case, if you have a matrix as a floor, what you have to do is:



If you show your code, I could check it for you.

cheers.

I'm not a grumpy grandpa
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 13th May 2011 15:23
And since the gun is only locked onto the camera how would I move the camera on the elevator?
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 14th May 2011 00:07
When we lock an object to the screen, it will be locked all the time, so we can put the camera in the same x,y,z of the object player (it should be hidden).

Cheers.

I'm not a grumpy grandpa
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 14th May 2011 01:22
Whenever I say where to put object 1 (my gun locked onto my camera)at same y position as elevator if it's touching my gun disappears as soon as the game is started
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 14th May 2011 15:08
chafari gave me an idea for adding elevators into the game I am working on as open source. I'll be using Sparkys collision so I'm just assuming the so long as the elevator does not move faster than the sphere radius of the collision area I am checking on my baddies and players the returned sliding values after the collision check should shift them up and back onto the elevator.

Fingers crossed the sliding collision will work as I don't want my baddies or my player to suddenly appear underneath the elevator. As soon as I've implemented something I will be posting all the code anyway.

Warning! May contain Nuts!
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 14th May 2011 22:04 Edited at: 14th May 2011 22:05
Quote: "I'll be using Sparkys collision"


Just tell me...are you going to use Darkbasic Pro or Darkbasic Clasic ? Dbpro is easier than old Darkbasic. If you use Sparkys collision, then collision won`t be any problem,and the player will move as speed as the elevator because you just have stay on the lift to go up or down with it.

You have to setup your object like that:


sc_setupComplexObject my_lift,1,2
position object my_lift,x,y,z
sc_updateobject my obect



Have a look here
http://forum.thegamecreators.com/?m=forum_view&t=184947&b=1


Cheers.

I'm not a grumpy grandpa
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 14th May 2011 23:01
How could I add small patches of water here and there over my matrix?
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 15th May 2011 01:57
Quote: "Whenever I say where to put object 1 (my gun locked onto my camera)at same y position as elevator if it's touching my gun disappears as soon as the game is started "


If your gun is locked to the camera, you don't ever have to position it again if it is going to be aiming forward. The thing you position is the CAMERA, and the gun will follow because it is locked.

Quote: "How could I add small patches of water here and there over my matrix?"


If your matrix has dips and valleys, it's actually quite easy. Create a plane and position it a little higher than ground level of the matrix and texture the plane with some kind of water texture.

Here's an example, I'm just going to make the water texture on the fly. It takes about 20 seconds to make the textures so be patient. Move around with Up and Down arrows and steer with the mouse:



Enjoy your day.
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 15th May 2011 03:35
@chafari - My project is in DBP.

Quote: ""Whenever I say where to put object 1 (my gun locked onto my camera)at same y position as elevator if it's touching my gun disappears as soon as the game is started ""


A little trick I used in another program I did which can be done the same here is to make the object much smaller and position it just in front on the camera (by fractions if needed) so that it only appears to be the same size as was originally intended. Anything then that it does come in contact with, the object will not affect it as much as what you've said with part of it disappearing.

Warning! May contain Nuts!
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 15th May 2011 04:12 Edited at: 15th May 2011 05:12
@WLGfx

When we use sparky`s , we don`t have to check any collision at all to get on the lift, if you stay over, you will go up with it.I will make an example for you.


Re-editet
Here I added the lift example.(Dbpro only)

cheers.

I'm not a grumpy grandpa

Attachments

Login to view attachments
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 15th May 2011 05:32 Edited at: 15th May 2011 05:40
Great I got water! thanks so much! Now. How do I move my first person camera on the elevator. I'm using the same camera as was in the monster hunt tutorial so could someone figure it out please?

Instead of "position object 1,x,my_floor+y#+2.5,z" what would I replace object 1 with for my camera?

and

for i= 56 to 57
if object collision(1,i) then y#=object position y(i)
next i

Instead of object collision(1,i) what would replace the 1 to move the camera?
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 15th May 2011 06:09
To my knowledge the camera cannot detect collision. I would suggest using the existing code to move a small object (a small box) and placing the camera inside of it (position the camera at the object's position).

Then you can just check for collision between the box and your environment.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 15th May 2011 07:10
What would the code look like to place the camera inside the box?
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 15th May 2011 13:33 Edited at: 15th May 2011 14:11
Quote: "I would suggest using the existing code to move a small object (a small box) and placing the camera inside of it "


Exact !! sometimes, we need object to detect collision (old Darkbasic), so you just place the camera on the same x,y,z of the box.




Quote: "What would the code look like to place the camera inside the box? "


Have a look in this piece of code how to place the camera in the coords of other object.(Darkbasic clasic)



Cheers.

I'm not a grumpy grandpa
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 15th May 2011 18:17 Edited at: 15th May 2011 19:11
I give up please get the elevator working. It's located on the south west corner of the map.


sorry but theres gonna be alot of songs,bitmaps,etc your gonna have to erase
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 15th May 2011 23:23
Quote: "I give up please get the elevator working"

You get rid very soon !! Don`t give up...never say that


Quote: "sorry but theres gonna be alot of songs,bitmaps,etc your gonna have to erase "


Could you please add your stuff in a rar file to test your program?

Cheers.

I'm not a grumpy grandpa
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 15th May 2011 23:51 Edited at: 16th May 2011 00:37
I can't it's more than 50 mb :\ My code is for the most part closely related to monster hunt tutorial so download that off this site and try to get it working on there
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 16th May 2011 19:19
@chafari - the download loaded up okay but the players object fell all the way down.

I'm gonna add something to my game after for a lift. Once it's completed I'll post it. I've just got my animated particles working.

I suppose for moving platforms, if collision is detected then the object that is colliding with the platform will has it's position changed otherwise the platform will move out of the way and the object will then fall.

Warning! May contain Nuts!
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 16th May 2011 20:44
Quote: "the download loaded up okay but the players object fell all the way down"


You need sparkys 2 dll

Try this exe.

I'm not a grumpy grandpa

Attachments

Login to view attachments
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 17th May 2011 00:30
That worked... Got a few ideas for some new levels in my game to incorporate lifts...

Warning! May contain Nuts!
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 17th May 2011 04:02
Okay so could someone please download http://www.thegamecreators.com/?m=view_product&id=2030&page=3d_tutorial_index and add an elevator to tut 25? I don't really understand why it's not working
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 17th May 2011 13:59 Edited at: 17th May 2011 14:17
Quote: "Okay so could someone please download ...."


Well I made ​​a little sloppy code to add a lift in tut 20 instead of tut 25 bacause the goblyn was driving me crazy... it need to be refined a lot, but you can see the idea,...you can implement putting more conditions.

Put the code into your tut source



Cheers.

I'm not a grumpy grandpa
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 17th May 2011 23:35
Chafari!! Thank you so much I finally have a working lift!!! Now just wondering how can I position it in the bottom left corner of the 10000,10000 matrix? It won't move at all :\
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th May 2011 01:52 Edited at: 18th May 2011 01:53
Quote: "Now just wondering how can I position it in the bottom left corner of the 10000,10000 matrix?"



If you refer how to position the lift I made for this tut, you have to realize that immediately I made the lift, I positioned at...

position object lift,5000,my#+40,5100

So if we want the lift in ...let´s say in 50,0,50 we have to position the lift in ...

position object lift,50,my#+40,50

my# is the ground height and +40 is the camera position y

Lastly, in the main loop (Do loop) we have to place the lift in:

position object lift,50,lifty,50

When we create the lift, is not so important to place it in correct position, but it is very important, to place it correctly in main loop. Try again

Cheers.

I'm not a grumpy grandpa
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 18th May 2011 02:45 Edited at: 18th May 2011 03:13
Wow silly me. There were two spots it needed to be changed since it was moving :p chafari while your on a roll, do you know how I would make something like this? http://www.google.com/imgres?imgurl=http://images.ijjimax.com/v2/arcade/gunz/guide_07_pic02.jpg&imgrefurl=http://gunz.ijji.com/guide.nhn%3Fm%3Dquestmode&usg=__EFIX6porgEb2UJCQC73z6MMmmE4=&h=317&w=424&sz=36&hl=en&start=10&zoom=1&tbnid=TGX-rSP2tUElfM:&tbnh=94&tbnw=126&ei=XQjTTf_DCpP0tgOPn923CQ&prev=/search%3Fq%3Dgunz%2Bquest%2Bportal%26um%3D1%26hl%3Den%26sa%3DN%26rlz%3D1C1CHKZ_enUS430US430%26biw%3D1280%26bih%3D709%26tbm%3Disch&um=1&itbs=1
I want to enter that 'portal' type thing to end the level.

My elevator is now acting very oddly. I'm trying to add a catwalk to get to the 'level ender' from the elevator. Check it out it's in the bottom left corner of the map.

I managed to make a file of my game eliminating almost all my bitmaps and such so here. Save it next to those tutorials of course since it has those files.
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th May 2011 13:44
Well ...the problem you had in your collision checking, was that you add two more objects (your catwalk and second floor)

Those object has number 57 & 58, and if you want to climb on them, you can not check...

if object collision(lift,58)>0

Camera has not collision at all, so the object helper(889), is to check if camera have any collision with the lift. It would be better to say camera helper than lift helper, but in the other case, we had just one object to climb...now we have three.

The way you have to do it, is check if object helper is colliding with any object you want to climb like 57 and 58 + lift but they are not consecutive numbers.

So we have to copy the same conditions for the lift to apply to objects 57&58.

for i= 57 to 58
if object collision(i,889)>0 bla bla bla....
next i


With this bucle we add same codition to all object into it.

I have made some arrangements to the code, and I add different speed to the goblyn (Move Object 3,3+rnd(2)) to leave me breathe .

The code needs to add even gravity, but it works. Here is the code.



I'm not a grumpy grandpa
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 18th May 2011 14:56
Wowowow thanks that's really good! Could you tell me exactly what it is that makes the goblin come back when he's dead and how to stop it?
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th May 2011 16:51
Quote: "Could you tell me exactly what it is that makes the goblin come back when he's dead and how to stop it? "

When we hit the goblin, or when goblin hit the player, the player is placed ramdomly in:

X#=rnd(10000)
Z#=rnd(10000)
Y#= get ground height(1,X#,Z#)

And the goblin is placed in:

mX#=rnd(10000)
mZ#=rnd(10000)
mY#= get ground height(1,mX#,mZ#)

Cheers.

I'm not a grumpy grandpa
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 19th May 2011 01:07
Trying to leave you alone but I can't figure this one out
I'm trying to make the goblin into a function so that I can add more level which have more goblins but I can't seem to find what's wrong with it now :\
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 19th May 2011 22:34
what I should do, when first level end, is to get a snap image and paste to the screen, or just fade in black with a notice....PLEASE WAIT...while we make some funktion to delete all sounds,musiks,images objects etc....and load all new stuff for second level.

Cheers.

I'm not a grumpy grandpa
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 20th May 2011 04:28
I just want to be able to add more than 1 goblin on each level :S
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 20th May 2011 10:47
Basically you will need to modularize the code that handles its motion. What that means:

It's probably in a subroutine, if it isn't, put it in one.

Change all references to an object number to a variable. So instead of MOVE OBJECT 1,.... you will turn it into MOVE OBJECT goblin,....

Using a for->next loop, change the variable's value to the value for the next goblin and call the subroutine.Then you can load all the goblins you want and just extend the bounds of the for next loop (once again, use a variable: FOR I= GoblinStartNumber to GoblinEndNumber).


Does that make sense?

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 21st May 2011 00:06
I'll try that BN2. Right now, though, I have a predicament. I have a portal I need to run into to go to the next level. However If I put it in the do loop it lags my game to the point it's not possible at all. Out of the do loop however it does nothing. What should I do?
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 21st May 2011 01:52
I don't know exactly what you've tried, but if you load the model when you create the world, then in the DO->LOOP you just check for collision with the object then gosub to the "generate the next level" code, it should work with little impact on frame rate.

Also make sure that you have SYNC ON called at the beginning of the code, SYNC RATE 0 immediately after it, and the SYNC command placed in your DO->Loop. These will deactivate the auto update of the screen and refresh every time SYNC is called. This will greatly improve your frame rates.

If for some reason you still get unreasonable lag, you could get really cheap and just assume that the portal is a sphere of radius R, and simply check:



Here, the Tolerance variable is going to be a small number (probably 1, but it depends on how big your world is). Basically this will check if the distance from the center of the portal is equal to the radius of the portal. If so, that means the player has walked into the portal and it's time to generate the next level.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
DarkBasicBegin
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location:
Posted: 21st May 2011 04:17
I have sync rate of 60 right now. have a sync in the do loop. Could you explain to me exactly what 'gosub' is? I have it in the game several times but it was there before I got ahold of it.

Login to post a reply

Server time is: 2024-03-29 06:31:49
Your offset time is: 2024-03-29 06:31:49