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 / Tornado Question?

Author
Message
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 24th Mar 2007 01:46
Hi, i was wondering if this was possible with darkbasic as a lot of things can be created with it.

I know at least one game that did it, but you are a tornado, and your goal is to rack up as much damage as possible and become bigger.

So my question is could i create a tornado that you control RTS mouse click style with just darbasic?

*excluding graphics for texture

http://img256.imageshack.us/img256/442/zombiesmk8.jpg
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 24th Mar 2007 03:20
yes that would be possible.

the tornados texture could be see through with ghost or fade object
the tornado could be rotated with rotate object
the tornado could be increased in size with scale object

a little bit of maths would draw in objects closer to its center via a distance function and a nice sin / cos approach

the RTS style movement has already been reproduced many times as snippets in areas of this forum


For objects within that game that were to tear apart would look better if they were limbed based objects combined to make the final models layout.

Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 24th Mar 2007 07:20
cool thanks indi, although this is way out of my league as i'm a newb, but now that i know it can be done. I have something to look forward to.

http://img256.imageshack.us/img256/442/zombiesmk8.jpg
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 25th Mar 2007 06:43
Ok, this isnt going to be helpful at all, but I just mocked this up in the last 5 minutes, to give you an idea of just how fast you can make whatever you can think of once you learn the ins and outs of a language >>



I dont recommend trying to learn from it, its very badly programmed, but if I spent 5 minutes on that, imagine what you could do in 5 weeks.

Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 25th Mar 2007 07:47
Wow ruccus, you did that in five minutes? Oh boy, i couldn't code that much in 2 hours, but i see your point. I'm being paitent and reading just about every tutorial i can find, i've gone from strings and variables to setting up a small shooter.

Currently, my problem is 2d as I was told to start there before 3d. (even though i didn't listen ) Anyway, i'm a newb and i can admit that and i'm willing to do whatever it takes to get better, so if you guys have any tutorials in the works, i'd love to read them, i'm running out of things to read here lol.

By the way ruccus, your code stopped running, it had a problem with

TYPE tornadoT

it didn't seem to like it, and i don't know how to fix it.

http://img256.imageshack.us/img256/442/zombiesmk8.jpg
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 25th Mar 2007 09:43
hey ruccus, you're using dbpro aren't you, because types are global and only arrays are global in dbc.

http://img256.imageshack.us/img256/442/zombiesmk8.jpg
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 25th Mar 2007 15:08 Edited at: 25th Mar 2007 15:13
Ah yes I am, sorry about that I forgot this was the DBC board.

Id post a DBC-compatible version but it really isnt worth it, the code is buggy even, nothing to learn from.

Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 25th Mar 2007 17:14
yea, i'm better off just experimenting.

http://img256.imageshack.us/img256/442/zombiesmk8.jpg
Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 25th Mar 2007 18:59
hahaha, i had a thought. Was any of that code worth looking at for examples, because it looks like it had some good things in it.


arrgghh! my sig won't show, i'm very sad, it was so cool and it was a gift too.

img256.imageshack.us/img256/442/zombiesmk8.jpg
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 25th Mar 2007 19:55
Use the IMG tags for the sig,



Heres basically whats happening in the code for the example;

1. The tornado object is a cone, flipped upside down so it looks like a tornado. The map is a matrix. And the debris is 99 objects (numbered from 2 to 100) with random meshs (sphere, cylinder, or cube).

2. To make the tornado spin, you would think simply yrotating it using the yrotate object command would do the job. But in doing that, if you were to use the move object command to move the tornado forward/backward, it would move in a circle because it's constantly turning. Instead, yrotate limb was used, with object 1, limb 0. Rotating limb 0 only rotates the mesh, not the object's actual angle. Thus, the tornado still spins, but using the move object command will move it forward/backward in a straight line, since it's y angle remains at 0.

3. The debris is randomly positioned around the matrix.

4. The tornado is moved using a very generic movement routine (not RTS style btw).

The usual movement technique would be something like this (if you're using arrow keys):



Which makes sense, and works. But it can be compacted into 1 line. If you figure that when a key is pressed it returns a 1, and when it isnt it returns a 0, then if you subtract the status of the downkey from the status of the upkey, what will you get? Well, when the upkey is pressed and the downkey isnt, its 1 - 0, you get 1. When the downkey is pressed and the upkey isnt, its 0 - 1, you get 0. When both are pressed, its 1 - 1, so 0. And when none are pressed its also 0 (0 - 0).

This number from the formula upkey-downkey can be used for the speed we move our object at. Like so;



If you want to move the object at speeds other than 1 or -1, you multiply speed by whatever speed you want to move at. If you want to move at 0.5 units per loop, you'd do speed = ( UPKEY() - DOWNKEY() ) * 0.5.

But there really isnt any need for the speed variable, you can just put the formula right into the move object command.



5. The tornado is rotated in much the same way. It uses leftkey-rightkey, which still generates either 1, -1, or 0. With this value you can use the YROTATE OBJECT command and use the value obtained, like so;



Why do we add the object's current y angle? Well the yrotate command isnt like the move command, yrotate will rotate an object on the y axis TO the specified degree, not BY the specified degree. So if we didnt add the object's current angle, it'd just constantly rotate to either 1 or -1. Hope that makes sense.

6. After the tornado is moved, a for loop is used, going from 2 to 100.



We let x represent a debris object number. This allows us to basically cycle through each debris object. For each cycle, we get the distance from the tornado to the debris, and if the distance is less than the tornado's "suck distance" (set in a type, tornado.suckRadius#), we move the object towards the tornado.

Moving the object towards the tornado is done by using the point object command to point an object toward the tornado, and then the move object command. At the same all of the debris strafes left using the move object left command, giving it a "being sucked into a circular motion" effect.

Finally, we check if the debris object distance is less than or equal to the tornado's suck distance / 2. If so, the debris is inside the tornado, and so we delete the debris object.

7. The camera routine is pretty basic. First its positioned at the tornado's position, then its rotated to the tornado's y angle + 45. The +45 bit allows us to see the tornado from an angle, kind of like an RTS view. Then the cam is moved backwards by 600 units, and up by 500 units. Finally the cam is pointed towards the tornado. All of this combined makes the camera follow the tornado from a distance in the sky, constantly pointing towards it.

Hope that helps a bit, but like I said its not the best way to do things.

Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Mar 2007 02:03
I swiped the textures from Ruccus to save a bit a time. This tornado is created using many particles, which use a curved value to simulate more accurate movement.



RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 26th Mar 2007 02:14
Thats pretty cool, next step is to make a tornado path .

Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 26th Mar 2007 02:16
Phaelax- Thank you for taking the time to optimize this code, but i have some bad news for you, i can't learn from or use it. It won't run in dbc becasue of types. Sorry.

Ruccus-Thak you again for such a detailed explination, i'm glad you all take the time to explain things, you don't have to, but you choose to take the time to help, and that means a lot.

By the way, would you like to join a community project that is being formed? Xenocythe,The Crazy, and myself are creating the first TGC Smash Bros. type game. Featuring heroes from darkbasic, we could use all the help avaialable, get the word out if you're interested.

[IMG]img256.imageshack.us/img256/442/zombiesmk8.jpg[/IMG]
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 26th Mar 2007 02:22
Quote: "the first TGC Smash Bros"


I beg to differ

Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 26th Mar 2007 02:30 Edited at: 26th Mar 2007 02:30
sorry ruccus, didn't know. That is really cool looking, i like the rts style health bars and the chat function is cool.

so is this just some friendly reminders that you were first or would you like to join up with us?

I personally think everyone i've talked to is funny as hell and i would enjoy working with each and every one of them, but i understand that people do have lives.

RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 26th Mar 2007 04:09
Sorry zombie, I really dont have the time right now. i wasnt trying to prove I was first.... ok I kind of was but... ok yeah thats all I was really doing .

Aye its pretty ironic, this community has enough extremely talented programmers on it that if they joined together, they could create a game that would rival next-gen games coming out now. Sadly though, its been attempted many times, and usually its either nobody has time, lack of leadership, or disagreement of gameplay techniques.

Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Mar 2007 05:02
Here's the tornado in DBC code. I actually had this ready last night, but when I exited DBC my screen remained black. All I had was a mouse arrow and so I had to reboot; no saved code. Didn't really have the patience to redo it at that moment.



Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 27th Mar 2007 19:30
thank you very much, although, i don't know if i can fix it, but its bringing up an unreconized paramater on this line.

set object transparency t,1

which is a shame, because its really nice you went through all that to make it. Is there anything i can do?

Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Mar 2007 21:02
just change that to "ghost object on t"

Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 27th Mar 2007 21:30 Edited at: 28th Mar 2007 21:09
oh cool, thanks

that is really asweome, i'm going to have a lot of fun just experimenting.

one more thing, i've read the code over several times and everything makes sense to me, my only problem is that i can't figure out how to work in making objects be drawn towards the vortex and adding a cube simulating a twister.

Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 29th Mar 2007 02:12
a question, to make more things be picked up and added on, would i use glue object to limb?

Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Mar 2007 19:36
That depends what you want to do with the object you pick up. If you just want the object to disappear, then delete or hide the object. If you want it to become part of the tornado then you'll have to add it to the array like the rest of the cubes. You can add another element to the array dimension and use that to store the object numbers instead of just defining 1-160 like I did.

Zombie 20
18
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 12th Apr 2007 15:59
well..i've tried everything i know how to do, and i can't for the life of me place blocks in there *which is pretty bad since i can do that* and i can't get the twister to grow in height without running into a problem i don't know how to solve, my main issue is with the height, do you guys know how i may alter the particle array for height?

Login to post a reply

Server time is: 2025-05-27 20:56:11
Your offset time is: 2025-05-27 20:56:11