Ok, let's see here. To load a model into DBP, you need the directory path to the file and a number that acts as the "referense" to your object. You then use the LOAD OBJECT command to, well, load the object
Here's some sample code:
MyObject = 1
Load Object "datamyobject.X", MyObject
Note that I'm using a variable to hold the object referense. This is commonly viewed as good coding pratice, and becides, it's alot easier to reference a variable than to have to remember all those numbers. Cuz remember, you'll probally have at least five models or so, more likely upwards of 10 or 20, along with your GUI (graphical user interface - this is what appears on the screen to show you your lives, health, shields, ammo, and other vitaly important info), music, sound effects, matrixs (if you like being old school
), terrains, etc. etc. And you have to have numbers for all of that stuff. So, it would be much easier on your brain to store all of those numbers in varyables
Also note that the varyable (sorry for my atrocious spelling, I'm very focused today
) DOES NOT have to have the same name as your object, i.e. I could have used any of the following instead:
object=1
player=1
gun=1
thingee=1
spongebob=1
squarepants=1
roundpants=1
or even this:
ILikePinkBunnies=1
But it's a wise idea to choose a name that agrees with what you're trying to load, so SpongeBob=1 is (probally) out. Same for the pink bunnies one.
OK, now for displaying your object on the screen. First let's have some sample code:
rem setup display options
sync on
sync rate 60
backdrop on
hide mouse
rem load object
MyObject = 1
Load Object "datamyobject.X",MyObject
`main loop
do
`slowly rotate object
YRotate Object MyObject, Object Angle Y(MyObject)+0.1
`don't forget to sync!
sync
loop
Since I don't know how much you know, I'm taking this as slowly as possible
First thing you'll notice (hopefuly) is the addition of the "rem" command. This isn't really a command isasmuch a reminder. It tells the complier to basicly ignore whatever's after that command on that line.
You'll also notice that abit further down, I seem to have changed all of the "rem" commands to a "`" (which is to the left of the 1 on most keyboards) This is exactilly the same as "rem", only it's a bit quicker to hit. I like using it for that reason, but you of course can do whatever you want.
Next thing we'll examine is this block of code at the very top of the mini-program:
rem setup display options
sync on
sync rate 60
backdrop on
hide mouse
The first line is just a reminder as to what this code does. I forgot to add this above, but reminders are mostly so you don't forget what your code does after a coupla days or so. Trust me, you'll forget it
The second line of code tells the complier to turn sync on. So what's sync, I hear you say. And why do we want it? Well, sync is what keeps your games smooth. You pretty much always want to set sync on. If you want a little more deatail, read this code snipper below. Otherwise, just skip it. But do come back to it later on, it's kinda nice knowing exactilly what you're doing at any time and with any command in your games
`sync tells the complier to refreash the screen only a certain
`number of times per second. In the case that i've shown you (the
`command, in case you've forgotten, was SYNC RATE 60) it tells
`the complier to refreash 60 times a second. Now while this may
`seem like a lot, but it's actually the smoothest you'll ever
`want your game to be. The accecpted standard for big games
`is generally 30 frames per second, but that's only if you have
`a HUGE number of objects on the screen at one time. Well, not
`huge as in HUGE, but huge as in a commerical game. Think
`Unreal Tournament or Halo. Those games (I think) are set to
`30 frames per second. There isn't much diffrense from 60 to 30
`BUT if the desired sync rate is above what the computer can
`handle, it'll suffer greatly in trying to keep up and will
`generally drop down 10 to 20 frames per second. Very bad :P
`Sooooooo... Why did I pick 60 instead of 30? For one,
`this program is very simple. All it does is display an object
`on the screen and rotate it. If it were a lot more complex,
`as in UT or Halo, I would set it to 30. But even then, most
`indi game developers can set SYNC RATE 60 without any probs.
Ok, next code block. To keep you from scrolling back and forth, I've put the code block below
rem load object
MyObject = 1
Load Object "datamyobject.X",MyObject
You probally already know what this does, since I explained it above. But I'll go over it again, just in case.
That code block consists of three lines:
First, it has a rem statement so you can remember what it was all about
Second, it creates a placeholder of sorts, so you don't have to remember a bunch of numbers (now let me see, is object 1274 the evil zombie boss, or is that the pink bunny? hmmmmm...
)
And third, it loads your object (either the zombie boss, or the pink bunny, doesn't matter which one you decide on
)
OK, next code block. Again, I've reprinted it here:
`main loop
do
`slowly rotate object
YRotate Object MyObject, Object Angle Y(MyObject)+0.1
`don't forget to sync!
sync
loop
This is easily the most important bit of code in the entire thing. (of course, there isn't much there to begin with, but you get the idea
) First, the now familiar reminder, except I've switched to the "`" notation instead of the "rem" commands. Once again, this is purely fluff; it doesn't do anything except remind you as to what the code does.
Second command! The "do" command. This is very important, but to understand it properly we need to skip to the eighth command: "loop" This is, quite simply enough, a loop. The complier keeps running through this bit of code, all of the stuff from "do" to "loop", pretty much forever. At least untill you decide you've had enough spinning objects, thank you very much, and now you want to start on your RPG!
Newbie note:
(READ THIS CAREFULY! IT IS VERY IMPORTANT!)
That bit about the RPG was a joke. Never, ever try to make an RPG unless you've been studying DBP for at least a year, perferably two or three. And even then, don't try posting about your grand new RPG
UNTIL YOU HAVE SCREENSHOTS AND A WORKING DEMO! Too many new ppl have been flamed for doing this. If you want an example, try searching for "Midtime" in the Work In Progrss section of the forums. Read it. Many, many, times. As far as I know, gothboy 101 is still working on it. Maybe he gave it up (I hope so.) But if you want to make a RPG (or for that matter, a MMONRPG or an Action RPG), kindly keep your mouth shut untill you've either
a) Come to the conclusion that making a RPG is impossible
or
b) Got a working demo with more than a untextured matrix and a sphere
OK, rant time is over. Back to the drawing board!
EDIT: THIS BRB IS LEFT IN BECAUSE... WELL, I DON'T WANT YOU TO BE OFFENDED
(oh, and don't TYPE IN ALL CAPS, EITHER, IT ALSO ANNOYS PEOPLE!
[again, more stuff is coming. I didn't want to lose all of that stuff I just typed
And don't take the RPG thing personaly, it's just that we've had a real rush of
Quote: "I WANNA GET A TEAM AND MAKE A MMONRPG!!! Comon doodz l37s g00!"
type of posts lately, and I want to keep the flames to a minimum. Get's too hot
]
Back to loops: So how do you exit if the loop is gotta repeat forever? Simple. Either you use the "END" command and quite the game, or if you want to go somewhere else (like back to a menu or somthing) you "GOTO" out of the loop. Note: Don't try using GOTO right away, it won't be pretty as you have all of your objects on the screen while your user is trying to navigate the menus. And what if they decide to start the game over? Better to wait on the l337 menus for a bit.
Newbie note: (this one isn't as important, but it's still useful)
l337, 1337, 31337, all of that means "elite." The idea is to take "elite" or "eleet" and subsitute numbers for some or all of the letters. This is generally regarded as a "haxor k15d 05 t61ng" and it is a good idea NOT to talk this way. It can really annoy people. Annoy them to the extent that they wouln't even post!
Yes, you heard that right. "haxor s933k" isn't "kewl," and neither is "txt spk" where you remove all of the vowels. But, you alrady know this if you've bothered to read all of the sticky on each section of the forums. (right? cuz if not, then do read them! espcially the one marked "n00bs read here!" It not only gives you a good education, but it will also make you laugh yourself out of your chair! Read it!
Ok, now that we have loops down (and the proper useage and misuseage of teh 31337 haxor spk!
), lets look at the reamainding code (linesn 3-7):
`main loop
do
`slowly rotate object
YRotate Object MyObject, Object Angle Y(MyObject)+0.1
`don't forget to sync!
sync
loop
First thing: a comment. Now, from that, can you figure out what the command below means? Think about it for a bit, and then read on.
...
Did you get it? Or are you just being lazy and reading on? If that's the case, GO BACK AND READ IT! Life is hard, anyone who says otherwise is trying to sell you somthing
...
Well? Did you get it? Yeah? So what is it? Correct! That is, if you said it rotates the object slowly. If you didn't, well... Read on!
The command we're looking at is, for a reference, this:
Quote: "YRotate Object MyObject, Object Angle Y(MyObject)+0.1"
Wow, you say, that's complicated! Well, says I, not if you take it slowly
EDIT: THIS ONE'S LEFT IN BECAUSE... WELL, IT'S FUNNY!
[aaaaaaaannd we'll be back, right after these messages! stay tuned!]
TheallnewbaconandcheeseburgerfromMcFoods! Threeslicesofcheesewithnicecrispybaconslowlyflamefrilledoverahotfreshn00b tryingtomakeaMMONRG!
Aaaaannnd we're back!
Again, the command we're looking at is this:
Quote: "YRotate Object MyObject, Object Angle Y(MyObject)+0.1"
To understand this command, you need a picture. Sooooo...
[be right back after I figure out how to link to the images in the pong tutorial without uploading them to a website
]
Yey! It worked!
The first thing you need to know is that all game programmers use the Cartisan Corodenate System. Yep, that's the thingee you learned in algebra but always whined about how you'd never use it. Well, guess again! Cuz you can't do anything without a basic knowledge of this...
I'll presume you know what CCS is for now. My head hurts already
OK, so... The code again:
`main loop
do
`slowly rotate object
YRotate Object MyObject, Object Angle Y(MyObject)+0.1
`don't forget to sync!
sync
loop
And the line we're looking at is this:
Quote: "YRotate Object MyObject, Object Angle Y(MyObject)+0.1"
What that does it rotate your object around the Y AXIS. The YRotate command is the "main" command; but the Object Angle Y is important aswell. Object Angle Y(MyObject) returns the value that is equal to the rotation of your object. Since we want to rotate it 0.1 degerees per SYNC (you haven't forgot about SYNC yet, have you? If you have, GO READ IT AGAIN!
), we have to get the current rotation of the object so we can rotate it by 0.1 degeres.
Next bit:
`don't forget to sync!
sync
This simply tells the complier that this is the point where everything has happened that is going to happen during this little bit of time. For more explanation, read the thingee about conserning the SYNC command
OK, I think that's about it! Oh, wait, it's not... You wanted to learn about bitmaps aswell... Here follows a quick tutorial on that:
The command you want is
Quote: "LOAD BITMAP "data\mybitmap", MyBitmap"
where MyBitmap is a unique number you've assigned to "handle" the bitmap. As for displaying it on the screen... Put this somewhere in the main loop
Quote: "Paste Bitmap MyBitmap"
actually, it might be this:
Quote: "Paste Image MyBitmap"
Uhmmmmmmmm... I don't know
Ah well... Guess you'll have to figure it out yourself...
Ok, NOW I'm finished. Hope this tutorial helps...
~Hawkeye
[EDIT: removed all of those pesky "be right back" thingees
]
Edit2: Wow, that's not a "simple tutorial"! Must be three pages... And all done on the fly, aswell. How long did *that* take? *looks at clock* Woah... I just spent 30minutes explaining all of this stuff with I could have just said use LOAD OBJECT and LOAD BITMAP
Ok, alright... But it was a lot a work
Bring out the mercenary in you!
http://www.davidtattersall.me.uk
Mercenaries2 Community (not yet, anyway, but coming soon! right?)