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 / [Tutorial] Just Purchased DB? Want to make an rpg?

Author
Message
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 4th Nov 2005 21:49 Edited at: 28th Oct 2006 03:55
*ANNOUNCEMENT*
I have decided that i am going to continue my tutorials in DBPro. Sorry for anyone wanting the tutorials for dbc but you can still follow along and maybe figure some things out along the way.
^ANNOUNCEMENT^

The following tutorial is assuming that you have just purchased Dark Basic, and will go over everything needed to start you off.

This tutorial is WIP, and progress will grow as it goes.

The Complete Basics


So You just bought Dark Basic? I bet your willing to make your game making dreams come true, aren't you? Everyone who started out with Dark Basic does, so dont feel nervous about it.

If your looking to make an RPG, you've come to the right place. I will go over with you, step by step, explaining everything on the way, of how to make an RPG.

So lets get started!

*Tutorial 1 - The Variable
Now, lets first open DB up. You can use ALT TAB to toggle between DB and this tutorial.

First of all, lets learn about variables. In an RPG, you'll need Health, Money, Player Levels, stats, etc. All these things shall be accounted by variables.

So lets get our first variable, shall we?

How about health - to store health, it will be a float. For a variable, all float variables should end with a ' # ' . For example, health would be not be stated as ' health ' in the code, but as ' health# ' . To assign the variable a value, its probobly exactly what you thought. It would look like this:
health# = 100
Now health doesn't have to be 100, but its a reasonable amount. When you compile the program, the program will not say ' 100 ', because we didn't make it do that. And thats exactly what we are gonna do next.
---------------------------------------------------------------------

*Tutorial 2 - Printing to the screen
Now that you know how to store a float variable, lets learn how to print it to the screen. Its easy, all you have to do is:
Print health#
Add it under the ' health#=100 ' and get:

health#=100
Print Health#

Compile, and you can see the program print the variable health#. It does exactly what it says : It Prints variable health#, you see?

Now, thats not how you print words - to print words, all you need is to replace ' health# ' with ' "words here" ' and you get the words
' words here ' on the screen.

Now, there is another variable that you can store - Its called a string variable. A string variable is not a value, but words in a sentence. And instead of adding the ' # ' you add a ' $ '.
For example, lets use the string variable ' HealthWords$ ' . To assign that variable words, you must simply do:

HealthWords$="Your Health is "
Print HealthWords$

As you might've guessed, that stores the words "Your Health Is " into the variable and prints it onto the screen.

I know what your thinking - how do you add the two variables we made together to form a sentence? Its in the next tutorial.
---------------------------------------------------------------------

*Tutorial 3 - Joining two different variables to Print
Its really quite simple - we must use the plus sign in order to do this. Also, you will learn of the function called ' str$() ' .

The plus sign is used for joining the two variables, HealthWords$ and health# (Notice the difference of # and $).

The ' str$() ' function is called a function because it has the
' () ' in it. What does that do? It allows you to put parameters into the function. This functions, will change a variable with #, into a variable with $. So inside the ' () ' you will put the variable
' health# ' as the parameter. It will look like this:

str$(health#)


Now this is where the plus sign comes in. so far our code should be:

health#=100
HealthWords$="Your Health Is "
Print HealthWords$


You see the ' Print HealthWords$ ' ? Add a plus ign after it, then add the ' str$(health#) after the plus sign. Compile it, and it should look like:

health#=100
HealthWords$="Your Health Is "
Print HealthWords$+str$(health#)


Hooray! We've done it! If you've come this far, your doing great!

Now I bet your thinking that health can't always be att 100, aren't you. Thats the next tutorial.
---------------------------------------------------------------------

*Tutorial 4 - Decreasing+Increasing the health variable
There is more then way to do it, and we will go over both ways.

In the past tutorials, you learned about two different variables, how to assign values to them, and how to join them together and print them to the screen.

Now, to increase and decrease the health.

Way #1-
health#=health#+1
What you are doing, is adding the same value to itself to increase it. For a deeper explanation, health#+1 equals 101, because health# used to be 100, and you are adding one to it. You are stating that health# now equals 101 by writing the code ' health#=health#+1 '. Do you under stand? It goes the same way with decreasing, you would just change the plus sign to a minus sign and - wala!

Way #2-
Inc health#,1
Inc, is actually a shorter way of sayng Increase. You are increasing health# by 1, by putting the one after health#. The comma is used for seperation between the variable and how much you want to increase by. It must always be between two different parameters. Now you see what this does. For decreasing, its just as simple. You just change the Inc, to Dec, which is short for Decrease.

So lets use both ways. Our code should be:

health#=100
HealthWords$="Your Health Is "
Print HealthWords$+str$(health#)


Add the ' Inc health#,1 ' to the bottom of that. Now, add this to the bottom of the Increase command:

HealthWords$="Your Health Is Now "
Print HealthWords$+str$(health#)

And your whole code should be:

health#=100
HealthWords$="Your Health Is "
Print HealthWords$+str$(health#)
Inc health#,1
HealthWords$="Your Health Is Now "
Print HealthWords$+str$(health#)


Compile, and you should see what happens.

But, I'm assuming you dont want the health to change by itslef so quickly. This is where the next tutorial starts!
---------------------------------------------------------------------

*Tutorial 5 - Making the Program Wait
There are two ways to do this - waiting for a key press or waiting for an amount of time.

Waiting for a key press is easy - its just the command ' Wait Key '.
Add that right before the ' Inc health#,1 ', and your code should be:

health#=100
HealthWords$="Your Health Is "
Print HealthWords$+str$(health#)
wait key
Inc health#,1
HealthWords$="Your Health Is Now "
Print HealthWords$+str$(health#)


Compile that code, and you can see that it waits for you to press space or return to continue.

There is also a way to make it an amount of time to wait for. You just have to change the ' key ' in ' wait key ' to an amount. But let me warn you - putting 1 does not mean one second. Putting 1000 would make it one second, actually.

So try it, you code should look like:

health#=100
HealthWords$="Your Health Is "
Print HealthWords$+str$(health#)
wait 1000
Inc health#,1
HealthWords$="Your Health Is Now "
Print HealthWords$+str$(health#)


Well, there you go! Thats waiting!
---------------------------------------------------------------------

*Tutorial 6 - Making a Program Loop
If you want your program to continue to keep going, and going, people use loops. From what I know, there are 4 kinds of loops. I will only tell you two right now, because its not important to learn all of them right now.

The First Kind of Loop-
It called the Do-Loop. It is called this, because the code for a Do-Loop would be set up as the following:

Do
*Your code here
Loop

What this does, is it goes from do, to loop, and keeps going from do to loop and going and doesn't stop unless you made it stop, which I will explain in another tutorial.
So for an exercise, make the program We had just made about health loop, by putting a do before the first command, and a loop after the last command. Watch what it does.

The Second Kind of Loop-
This is called the for-next loop. This one is also a little more complicated then the Do-Loop, but you will manage. The Code shall be setup like this:

for health=1 to 5
Print str$(health)
next health

Its more of an example then a setup, but it makes more sense like this. Put this after you current code, but right before the ' Loop ' command. Your code should Now look Like this:

Do
health#=100
HealthWords$="Your Health Is "
Print HealthWords$+str$(health#)
wait 1000
Inc health#,1
HealthWords$="Your Health Is Now "
Print HealthWords$+str$(health#)
for health=1 to 5
Print str$(health)
next health
Loop


Are you understanding these loops? I sure hope you are, because they are really important to make an RPG.
----------------------------------------------------------------------

*Tutorial 7 - Text Commands
First off, if you want to position where the text appears when you use the ' Print ' command, you have to use the ' Set Cursor x,y ' command. The ' x ' should be replaced with the X value on the screen (From left to right, higher number will be further right). The ' y ' should be replaced with the Y value on the screen (Up and Down, higher number will be further down). So If you want to position words onto the screen, you will have to do the following:

Set Cursor x,y
Print "words"

Pretty anoyying huh?

Well there is a solution to that. Instead of using Two commands, you only have to use one, and it is: ' text x,y,"Words" '. Its pretty much just the two command Set Cursor and Print combined.

Unlike ' print ', ' text ' can be changed by Font, Size, and can be Italic, and/or bold.

To Size the Text:
Set Text Size *sizevalue (Replace the ' *sizevalue ' with the size of the text)
To Change the Font:
Set Text Font *font (Replace the ' *font ' with the font type

Bold: Set Text to Bold |-| Italic: Set text to Italic
Bold+Italic: Set Text to BOLDITALIC |-| Normal: Set text to normal

Also, just plain white text and black background all the time is boring. Thinking what I'm thinking?
Use the command ' Ink rgb(r,g,b),rgb(r,g,b) '. It seems a little complicated, but like before, you'll manage. First Of all, the comma I made bold is seperating the parameters. The one to the left of the bold comma is the color of the text in rgb(r,g,b). The r stands for red, b stands for blue, and g stands for green. As you are thinking, changing the r g and b inside the parenthesis change the red green and blue value of the text color. Its the same with the rgb(r,g,b) to the right of the bold comma, except that it changes the background color.

Well, thats about all you need to know about text. Mess around with everything I've taught you so far, its enough to even make a small text game. But Did you ever wonder, how to make a button with this text? Find out next tutorial!
----------------------------------------------------------------------

*Tutorial 8 - The Text Button
To do this tutorial, we will need a better sense of 2D coordinates (x and y) . I've drawn a simple image which I can explain easily:
http://www.solisearch.net/ims/pic.php?u=191602SZkT&i=240289
The red line is the Y axis in this image, the 0 in red at the top of the page indicates you, that this is where the y axis starts. If the y axis should increase, the arrow would move down. Get it?

Its the same with the x axis- If the x axis should increase, the blue arrow would move right. I think its time to actually move onto the button now.

Learning coordinates is what we need to find where you shall click to trigger the button.

Lets refresh our minds and our code, shall we? Erase all your code. Dont worry, I'm sure you can wip it all up in 2 seconds now!

Now, as an exercise, I'm going to ask you to make a do-loop, and make text at the x coordinate of 20, and the y coordinate of 55. Make the text say "Click Me!" AND USE 'Click me!' WITH A VARIABLE CALLED WORDS$ ! . Can you do this? I'll wait.

If you think you got it, then great job! If not, look back at the tutorials to see how we did it before.

Your code should be:
WORDS$="Click Me!"
Do
text 20,55,WORDS$
loop

Moving on!
Now, for a button we need 2 x corrdinates, and 2 y coordinates. Yes, so you would have x1,y1,x2,y2. Those would be the parameters.

You probobly know what the x2 and y1 are - they are the coordinates where you positioned the text. So x1 is 20, and y1 is 55.

How in the world do you find out x2 and y2? Easy. There is another function for this. Its called text hieght() and text width(). The two, as you assumed, will get the hight and width (x2 and y2) of the text.
We must add the ' /2 ' after Text Height(), which divides it by two to get a more reasonable button.
So lets get the parameters into variables, shall we? We done need a
' # ' or an ' $ ' . We wouldn't use any at all, cause we dont need them here (Woah, first smiley in the whole tutorial!)

To set the variables:
x1=20
y1=55
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)/2

You see, by using the Text Width() and Text Height() functions, there must be a parameter inside the parenthesis. The parameter, of course, would be the variable of the text! So put that code of the variables, right before the do-loop, and right after the ' WORDS$="Click Me!"
(Now that we have defined the text's corrdinates to be positioned at, we can just replace the 20 and 55 with x1 and y1)

Your code should be:
WORDS$="Click Me!"
x1=20
y1=55
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
Do
text x1,y1,WORDS$
loop

Now, clicking part! As you know, we click with the mouse button. The mouse button is usefull in may things, but we choose clicking here.

We are gonna need the parameters of the mouse. We are gonna need its X and Y. There are more functions for this! Yay functions! They are called Mousex() and simply Mousey(). Now, this is the most challeging and complicated part, so I'll draw an image for it too:
http://www.solisearch.net/ims/pic.php?u=191602SZkT&i=240290

You see, for you to click on the button, the mouse must be greater then x1 and y1, but less then x2 and y2. I think that explains it, does it not? It it were less then x1 and y1 then you could click the button even when the cursor wasn't on the text!

Now, to learn this, there is another thing I must teach you. It is called, the If-endif statement! What you can do is determine ' If ' something happens, whether it is about variables, or even if you clicked the mouse. Although, for every If, you need an Endif. So here is the code. Look at the previous image, and try to figur out with math how its finding the coordinates

if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2

endif
endif

Understand?
Well, we have where to click the button... now to click it!
We need another If-endif statement. Although, to see if you click the mouse, there is the function ' mouseclick() '. For mouselcick to be one, is to click the left mouse button. But here, lets use a trigger. The trigger is a variable that when equals 1, it starts something. So the code would be:

if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif


(Notice the two endif's for the two If statements. As you can see, the trigger is called 'Pressed')
For this trigger to work, at the very top of our code, we shall put ' Pressed=0 ' to tell the program that the trigger shouldn't be on yet.
So what do you want to do when you click the button? How about we trigger it to start the game? Thats the next lesson!

Right now, your full code should be:
Pressed=0
WORDS$="Click Me!"
x1=20
y1=55
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
Do
text x1,y1,WORDS$
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
loop

(We had put the Button part inside the loop only because we want you to be able to click it whenever)
----------------------------------------------------------------------

*Tutorial 9 - The Text Button Part 2
So you know how to create the button and find out where to click on it. Now its time to put it to works for the RPG!

We gotta put what happens when the trigger ' Pressed ' is triggered. Put this code underneath the two endif's in the loop:
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif

First of all, (the first line) its saying then when Pressed is Triggered, it will change the color from RED to White. You notice that 'then' and the 'else' ? That is a way of shortening an IF statement.
Second of all, its saying ' when Pressed is triggered '. Third of all, its saying that pressed equals clicking the mouse. So right now, the mouse hasn't been clicked at all, there for pressed is once again 0. Once you click, it will be 1 again, and the function will end.
Get the final code from last Tutorial, and change the WORDS$="Click Me!" to WORDS$="New Game" .

Now, what shall happen when you click the button 'New Game' ? We are gonna have to get out of the loop, so this is where GOTO comes in.

Under neath the ' loop ' command, about 2 lines below, write the words
New_Game:
The words ' New_Game: ' are known as a label. If you use a GOTO, you need a label.

So underneath where it says:
Pressed=Mouseclick()

Put ' If mouseclick()=1 then Goto New_Game '

(When using the GOTO command you don't include the ' : ' but you include it in the label)
Your code should now be:

WORDS$="New Game"
Pressed=0
x1=20
y1=55
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
Do
text x1,y1,WORDS$
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
If mouseclick()=1 then Goto New_Game
else
pressed = 0
endif
loop

New_Game:

Are you following me? Before you test this code out, underneath the ' New_Game: ' label, put the command ' CLS '. ' CLS ' actually means Clear Screen. It does exactly what it says, it clears the screen!

Now, Underneath that, put the command ' Print "Get Ready to play"; '
You see the ' ; ' ? That means it'll wait, so underneath the Print command, put ' Wait 2000 '.

Test it out, and wala! You have your start game button! Feel Free to position it anywhere you would like, because we'll be adding more buttons.

Your Final Code:
WORDS$="New Game"
Pressed=0
x1=20
y1=55
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
Do
text x1,y1,WORDS$
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
If mouseclick()=1 then Goto New_Game
else
pressed = 0
endif
loop

New_Game:

cls
Text 240,220,"Get Ready to Play";
wait 2000
----------------------------------------------------------------------

*Tutorial 10 - The Text Menu
For this lesson, we will add more then just ' New Game ' to make a complete menu. We will also learn so many other things that are important. This is a well packed lesson.

You might be thinking ' It took so much code for just one button, new we are gonna do more? '. Well, there is a solution. You have learned different functions like mousex(), and str$(). Now, we are going to be able to make our own function! It'll be a button function, of course.

First off, to make a function, you need a function header. It looks like this:
function FUNCTIONname(parameters)

The word ' function ' in the beginning is always the same, stating that it is a function, so never change that. The ' FUNCTIONname ' or course, we will replace with the word ' Button ' because this is a button function. The parameters, we'll get to that later. (Functions should always be at the bottom of all code, so do all this at the bottom)
It should now be:
function Button(parameters)

Now, the only parameters we need are 3 things: The x1,y1,and WORDS$. This is only because its just like the command ' text ', and for a button, we need text (WOOT second smiley!)
So this is now the code:
function Button(x1,y1,WORDS$)

Since we will have the ' words ' here, in the final code for the last tutorial, remove the ' WORDS$="New Game" ' and the
' text x1,y1,WORDS$ ' . This is because in the function, we will tell what the words are.

Now that you have a header, its time to put the code in the function. First off, take this code from the top, and put it under neath the header:

Pressed=0
x1=20
y1=55
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)

I want you now to remove the:
x1=20
y1=55

This is because we are telling what x1 and y1 are in the function.

Now, from last's tutorials final code, remove this code and put it underneath what we just put in:

if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
If mouseclick()=1 then Goto New_Game
else
pressed = 0
endif

Also, remove the ' If mouseclick()=1 then Goto New_Game ' because we will take care of that later. You code should now be:

Do

loop

New_Game:
cls
Text 240,220,"Get Ready to Play";
wait 2000

function Button(x1,y1,WORDS$)
Pressed=0
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif

Well, thats actually all there is to make the function. Although, we must once again put ' text x1,y1,WORDS$ ' at the end of this. To really end this, add a ' endfunction pressed ' at the bottom. Thats saying that it will end the function when pressed is triggered. Although, you should always have at least a ' endfunction ' at the bottom of your function.

Now, to call the function to make it work. inside the do-loop, put
' Button(x1,y1,WORDS$) '. This is calling the function, by writing the name and the parameters. Now, to change the parameters to make it work. Change x1 to 20, and y1 to 55. Change WORDS$ to ' "New Game" '. It should look like this:
Button(20,55,"New Game")

Now, the use of a function, is to use another button, all you have to do is put it again. Underneath ' Button(20,55,"New Game") ', put that once again, but change y1 to 95. Also, change WORDS$ to ' "Load Game '
and inside the do-loop it should look like:
Button(20,55,"New Game")
Button(20,95,"Load Game")

Although, we want to do what happens when you click the ' New Game ' button, right? Change the ' Button(20,55,"New Game") ' to an If-Then statement by making it like this:

if Button(20,55,"New Game")=1 then

You see the ' =1 '? Thats saying when Pressed is triggered, because we have in the function ' endfunction Pressed '. So now, after ' then ', put ' Goto New_Game ' to once again go to the label. You code should so far be:

Do
if Button(20,55,"New Game")=1 then Goto New_Game
Button(20,95,"Load Game")
loop

New_Game:
cls
Text 240,220,"Get Ready to Play";
wait 2000

function Button(x1,y1,WORDS$)
Pressed=0
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1,y1,WORDS$
endfunction pressed

Since Load Game will not work because we didn't make it work yet, lets add another button, how about the ' Exit ' Button (Its the third, but its starting to get lame to count it). So once again, inside the loop but after the Load Game button, put:
Button(x1,y1,WORDS$)

For an exersize, make that button say "Exit", and make it the same X coordinate, but 40 Y coordinates down. If you get stuck, look back at the tutorials to see how we did it before.

It should look like this:
Button(20,135,"Exit")

To change that to an if, it should look like this:
If Button(20,135,"Exit")=1 then

Understand? Now, to make it actually exit is simple. Just write the command ' End ' after the then. Wala! Your code should be:

Do
if Button(20,55,"New Game")=1 then Goto New_Game
Button(20,95,"Load Game")
If Button(20,135,"Exit")=1 then End
loop

New_Game:
cls
Text 240,220,"Get Ready to Play";
wait 2000

function Button(x1,y1,WORDS$)
Pressed=0
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1,y1,WORDS$
endfunction pressed

Test it out, and you have a menu!
----------------------------------------------------------------------

*Tutorial 11 - Starting the 3D
Now that we have a menu, I think its time to start the 3D part of the RPG. First of all, you have to know, that whenever you have 3D, you need sync. Sync Is the thing in a game that refreshes the game, to make it run smoother. To set it on, all you have to do is ' Sync On ' at the top of your program! Easy, huh? (NEVER Put ' Sync On ' inside a loop!). Now, here is another command of sync:
' Sync Rate *rate '
All you have to do is replace the ' *rate ' with the sync rate. That means the rate it will refresh the screen at. So, for Maximum performance, we shall set the rate at 0.

So at the top of our final code from last tutorial, put:

Sync On : Sync Rate 0


You see that ' : ' in between those commands? It can be used between any commands, because it is a stacker. A stacker is what is used to stack commands next to each other. It saves room, which is useful for some people.

Now, we need to refresh the game inside of the loop. So in last tutorial's final code, with the Sync added to it, put this command RIGHT before the word ' loop ': ' sync '. This is telling the program to refresh at that period, which is good.

Remember when I told you that there where 4 kinds of loops? We learned two, its time to lean another. Its called : The Repeat-Until. This is very handy, as you can set parameters for when it should stop looping!
Example:

Repeat
*code
Until *parameter

Just replace the ' *parameter ' with the function or variable it will stop looping at. Another example:

Repeat
Print "Yay Third loop!
Until returnkey()=1

The function ' returnkey() ' is a function that responds the the return key (AKA the enter key). ' returnkey()=1 ' is stating that when the return key is pressed. So, remember this code?:
New_Game:
cls
Text 240,220,"Get Ready to Play";
wait 2000

Thats the New Game lable, right? Well now that we have sync, it won't work without a loop and a sync itself! This is where we use the Repeat-Until loop. But First, I must teach you another useful function. Its called ' scancode() ' What this does, is check if one of the keys on the keyboard is pressed. Every key has its own scancode. So ' scancode()>0 ' means that if any key is pressed, even the letters. Lets make ' scandcode()>0 ' the new Repeat-Until Parameter now. To get the New Game thing to work, we must take the code:
cls
Text 240,220,"Get Ready to Play";
wait 2000

and put it into the Repeat-Until in place of the ' *code '. Now, take out the ' cls ' and the ' Wait 2000 '. Your New Game code should look like this:

New_Game:
Repeat
Text 240,220,"Get Ready to Play";
Until scancode()>0

Add a ' sync ' before the ' Until scancode()>0 '. Add a ' cls ' Before the ' Repeat '.

Your code should now look like this in all:

Sync On : Sync Rate 0
Do
if Button(20,55,"New Game")=1 then Goto New_Game
Button(20,95,"Load Game")
If Button(20,135,"Exit")=1 then End
sync
loop

New_Game:
cls
Repeat
Text 240,220,"Get Ready to Play";
sync
Until scancode()>0

function Button(x1,y1,WORDS$)
Pressed=0
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1,y1,WORDS$
endfunction pressed


Now for the REAL 3D. First of all, we want a box for the player just for now. You can put objects like boxes, spheres, and stuff in place of real objects when you dont have a real object yet, like a house, or a player. To make a box, the command is simply:
' Make Object Box *obj,*x,*y,*z '
Confused, right? Well you never heard of the parameter ' *z ' before have you? Well, I've Drawn another image to help us:
http://www.solisearch.net/ims/pic.php?u=191602SZkT&i=244884
Do you understand this? I hope you do, cause if you dont it will be harder to understand. So lets get back to making the box. The command was: ' Make Object Box *obj,*x,*y,*z '. So lets make the x,y, and z size of the box. How about x is 4, y is 3, and z is 5. As for the
' *obj ', you must understand that it stands for the Object Number. Every object you have must have a number so you can operate it. Lets make this object number 1.
The command now looks like: ' Make Object Box 1,4,3,5 '. Put this command after:

New_Game:
cls
Repeat
Text 240,220,"Get Ready to Play";
sync
Until scancode()>0

Now, lets make it so we can once again wait to end the program, but this time by the ' returnkey()=1 ' instead. For an exercise, make the program wait untl you press the return key with a Repeat-Until, and add a sync. If you think you got it, it should look like this.

Repeat
sync
Until returnkey()=1

Add that code under the ' make object box 1,4,3,5 ' command.

And RIGHT before the ' function Button(x1,y1,WORDS$) ', you should put ' end ' You see, what this does, is end the program before it hits a function header.

Run this final code, you'll see you've made your first box!:


Sync On : Sync Rate 0
Do
if Button(20,55,"New Game")=1 then Goto New_Game
Button(20,95,"Load Game")
If Button(20,135,"Exit")=1 then End
sync
loop

New_Game:
cls
Repeat
Text 240,220,"Get Ready to Play";
sync
Until scancode()>0
make object box 1,4,3,5
Repeat
sync
Until returnkey()=1
end

function Button(x1,y1,WORDS$)
Pressed=0
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1,y1,WORDS$
endfunction pressed

----------------------------------------------------------------------

*Tutorial 12 - Organizing the Player
Now that you've made your first 3 Dimensional object, it's time to actually make that box, that little box, your main character (for now). Well, with a main character, you can't just stare at it the whole game. How about some movenment? Although we dont want it moving itslef. This is where a little thing called 'Player Input' comes in. Player Input is simple, really, Player Input is what ever the person playing the game inputs into the keyboard, or even the mouse. By that I mean that if you want the game to continue on, you are waiting for the players input of the keyboard ( wait key and scancode() ). Or if you want the main character to enter a building, you press the enter key ( returnkey() ). Understand?

So now we are going to work with player input, for moving the main character.

I am going to give you two choices, show you two ways of how you can setup keys for main character movement. The first way is the original 'up, left, down, and right arrow keys' movement. The second way is the
'W, A, S, D classic rpg' movement. Lets start with arrow keys first.

The arrow keys on your keyboard all have their own little special function for player input. Yay functions! They are very simple to read, and very simple to understand. The up arrow would be 'upkey()', the left arrow would be 'leftkey()', down arrow would be 'downkey()', and right arrow would be 'rightkey()'. Now, to tell if one of these are pressed, you need an IF statment. remember these old things?

So this is what it would look like: 'If Upkey()' . What this means is if the up arrow is pressed. But what if you want to detect if the up arrow is not pressed? Uh-oh, here come the parameters. Instead of
'If Upkey()' we can have it equal a parameter like so: 'If Upkey()=' .
There can be two parameters. 'If Upkey()=1' Is the same thing as
'If Upkey()', it is checking if the player presses the up arrow. Although, 'If Upkey()=0' is checking if the player is not pressing the up arrow, which could be useful in some cases. So lets just use 'If Upkey()=1' for the sake of parameters.
Although you must remember, at the end of an IF statement without the 'then' you must always have an 'endif'. So here it is folks:

If Upkey()=1

endif

Not so exciting yet, because we didn't make it do anything. Thats the next part.

*Drum Rolls Please!* Dum-dum dum-dum-dum dum-duuum! Ladies and gentlemen, Nerds and Geeks, Losers and Wackos of all ages! WE LEARN A NEW COMMAND! WOOT!

Ok, so yeah. We get to learn a new command. Not a new function, a new command! This command, this precious command, isn't some lame thing like 'Print', Nor is it anything like 'Ink'!
It's 'Move Object *obj, *speed ' !!! yay! This command, makes the object move forward! The object that you move is specified in the parameter '*obj', and the speed it moves at is specified in the parameter '*speed' ! Alright it wasn't that exciting, but I just felt like doing that... . Ok, so our object number for the main character is 1 so replace '*obj' with 1. The speed can be something as simple as 2, so replace '*speed' with 2. Put that entire new command inside of the IF statement, and it should ook like this:

If Upkey()=1
Move Object 1,2
endif

Now that we've got moving forward covered, we need moving backwords. So copy that entire IF statement and paste another one below it. Change 'If Upkey()=1' to 'If Downkey()=1' and change 'Move Object 1,4'
to 'Move Object 1,-4'. We changed it to down key because this is for moving backwords. We changed the '*speed' of 4 to a speed of -4 because if 4 made us go forward, than -4 will make us go backwrods logically, right? Should look like this:

If Upkey()=1
Move Object 1,2
endif
If Downkey()=1
Move Object 1,-2
endif

Next, since we have arrow key movement, left and right will turn the main character left and right. This is another new command, and its just as simple. It's 'Turn Object Left *obj, *speed' and
'Turn Object Right *obj, *speed'. '*obj' Of course is 1, and '*speed' can be... how about 2 (or 3, whatever suits you). So once again make IF statements and put the 'leftkey()' and 'rightkey()' functions. Put the turning commands for the right functions and your coe should look like this:

If Upkey()=1
Move Object 1,2
endif
If Downkey()=1
Move Object 1,-2
endif
If Leftkey()=1
Turn Object Left 1,2
endif
If Rightkey()=1
Turn Object Right 1,2
endif

Well there is your movement code so far! Your latest RPG code was:

Sync On : Sync Rate 0
Do
if Button(20,55,"New Game")=1 then Goto New_Game
Button(20,95,"Load Game")
If Button(20,135,"Exit")=1 then End
sync
loop

New_Game:
cls
Repeat
Text 240,220,"Get Ready to Play";
sync
Until scancode()>0
make object box 1,4,3,5
Repeat
sync
Until returnkey()=1
end

function Button(x1,y1,WORDS$)
Pressed=0
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1,y1,WORDS$
endfunction pressed

-Right? So you see where it says:

Repeat
sync
Until returnkey()=1

Under the 'New_Game' label? This is where we will have the main game code, so now I'm gonna test you. Change that 'Repeat-Until' loop into a 'Do-Loop' loop and it should look like this:

Do
sync
Loop

Now, Put the movement code with the movement input functions and IF statements right above where it says 'sync' because we want to sync the program at the end of each loop. Now put all that code back into your RPG and it should look like this:

Sync On : Sync Rate 0
Do
if Button(20,55,"New Game")=1 then Goto New_Game
Button(20,95,"Load Game")
If Button(20,135,"Exit")=1 then End
sync
loop

New_Game:
cls
Repeat
Text 240,220,"Get Ready to Play";
sync
Until scancode()>0
make object box 1,4,3,5
Do

If Upkey()=1
Move Object 1,2
endif
If Downkey()=1
Move Object 1,-2
endif
If Leftkey()=1
Turn Object Left 1,2
endif
If Rightkey()=1
Turn Object Right 1,2
endif

sync
Loop
end

function Button(x1,y1,WORDS$)
Pressed=0
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1,y1,WORDS$
endfunction pressed

Ok, so run that code, and you can move the box! (Start with moving it forward so your can see it if you move it backwards. Great isn't it! But, ouch, it moves out of sight sometimes! We can fix that by making the camera always face the object(for now)! So the command is as easy as 'Point Camera *x, *y, *z' You remeber the 3 parameters for the axis' of 3D space? E Y and Z! These can easily be represented by three cool new functions, 'object position x(*obj)',
'object position y(*obj)', and 'object position z(*obj)'! We can of course replace *obj with 1, the object number of our main character and the command will look like this:

Point Camera object position x(1),object position y(1),object position z(1)

Put that in your main program loop right under the movement and right above the sync. Next, we want something as a ground that we can see that we are moving on. This will be called a 'matrix'. A matrix is pretty much a grid with tiles, and these tiles can be moved around to make the shape of a ground. But this is only a ground for now. The command is 'Make Matrix *matrix, *width, *height, *xSeg, *zSeg'. Pretty complicated huh? Well first of all, matrix' have their own set of numbers because they are not referred to as objects. SO we CAN make this matrix matrix number 1. Replace '*matrix' with 1. Next, lets look at '*width' and '*height'. Width would pretty much be how big you want it on the x axis and Height is how big you want it on the x axis (even though it sounds like the y axis). Lets make the width and the height both 200. So now lets go to '*xSeg' and '*zSeg'. These are how many tiles you want in the matrix, so lets make both of these 5. Since there are 2 fives, there will be 25 tiles in this matrix (5 times 5). Ok, so lets put this entire command under where you make the main character box object and it should look like this:

make matrix 1,200,200,5,5

Now, we want the player to be in the middle of the matrix, so we position the matrix with 'Position Matrix *matrix, *x, *y, *z'. Since we want the player to be in the middle, we are going to move the matrix. The matrix we have is number 1. If the matrix is 200 in width (*x) and 200 in height (*z) the the middle of that would be 100 *x and 100 *z. Although, since the matrix is at coordinates 0 *x and 0 *z we must move it 100 spaces back, so the coordinates for '*x' and '*z' will be -100. Leave '*y' at 0, because we dont want to move it up or down. The entire command will look something along the lines of:

Position Matrix 1,-100,0,-100

Put that under 'Make Matrix' and your entire and final code should look like this:

Sync On : Sync Rate 0
Do
if Button(20,55,"New Game")=1 then Goto New_Game
Button(20,95,"Load Game")
If Button(20,135,"Exit")=1 then End
sync
loop

New_Game:
cls
Repeat
Text 240,220,"Get Ready to Play";
sync
Until scancode()>0
make object box 1,4,3,5
make matrix 1,200,200,5,5
Position Matrix 1,-100,0,-100
Do

If Upkey()=1
Move Object 1,2
endif
If Downkey()=1
Move Object 1,-2
endif
If Leftkey()=1
Turn Object Left 1,2
endif
If Rightkey()=1
Turn Object Right 1,2
endif

Point Camera object position x(1),object position y(1),object position z(1)

sync
Loop
end

function Button(x1,y1,WORDS$)
Pressed=0
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1,y1,WORDS$
endfunction pressed

Compile it, and wa-la! It's beautiful!


----------------------------------------------------------------------

*Tutorial 13 - Organizing the Player 2
Well, having the camera in one place is kind of dull for an rpg, dont you think? Otherwise, you would have to go through finding the perfect camera positions and angles for each scene in the game. So how about we just make it 3rd Person? Its pretty easy, so here it goes.

There are some commands I would like to get out of the way before we get started.

I hope you remember :
object position x(1) object position y(1) object position z(1)

Because those are very useful functions. They get the x, y, and z position of the specified object. Very useful, as we will use them alot.

Now, there is :
object angle x(1) object angle y(1) object angle z(1)

And they get the angles of each axis for the specified object. Understand?

Ok, so you know those. There is first, one thing we should do, one thing we should change before we move on. You remember turning left and right? That was interesting to learn, wasn't it? We used 'Turn object right' and 'Turn object left'. Well, we need to change that, if you want 3rd person camera in your RPG. We need to change it to a variable. You see, all we have to do is increase, and decrease this variable. This will be variable 'a#'. Now, all you have to do is replace:

Turn object left 1,2

With:

Dec a#,2

But as you see that is only for the left turning. Here is a little test. How would you change turning on the right?

Ok, if you think you got it, what you had to do was replace:

Turn object right 1,2

With:

Inc a#,2

You might not understand, but see what we do next. After the 'endif' in turning right, add this command:

YRotate Object *objnum,*value

What that command does is rotate the specified object on the Y axis in 3D space, by the specified value. That is, ofcourse, turning. So, replace the '*objnum' with '1' and the '*value' with 'a#'. Is it making more sense? When you click the 'leftkey()', it decreases 'a#', making it so it rotates you less (to the left) on the Y axis. And its vice-versa for the 'rightkey()'. Your turning should look like this:

If Leftkey()=1
Dec a#,2
endif
If Rightkey()=1
Inc a#,2
endif
yrotate object 1,a#

Understand?

Now, all we need to do is math. Math, and camera commands. First of all, after the turning code, we need to declare two variables that use previous variables, functions, and trigonometry. We will declare the variables 'posx#' and 'posz#'. So lets set that up.

posx#=
posz#=

Now, we must add the trigonometry functions.

posx#=cos( )
posz#=sin( )

I'm sure you know what these do? We have to enter an angle in there, between the parenthesis. Those functions find the cosine and sine of the angle we enter. This is what we should enter:

posx#=cos(270-a#)
posz#=sin(270-a#)

Well, you probably understand that we have 'a#' in there for the players Y rotation. But why the 270? Well in third peron's view, we have to look in the characters' line of sight, so we must use that 270 to do that.
Now we have to add the object position x(1), and object position z(1) to the end of the functions with addition. (Note the pos'x' and the pos'z') This is so we know that it will be behind the character, the specified object number 1.

posx#=cos(270-a#) + object position x(1)
posz#=sin(270-a#) + object position z(1)

But if we used that, it would be first person. *Aha, thats something to think about later on!*. But we want a third person rpg... right?
So we just have to add some simple multiplication in between.
Put ' * 30' before the addition sign. That is to move the camera farther back behind the character.

posx#=cos(270-a#) * 30 + object position x(1)
posz#=sin(270-a#) * 30 + object position z(1)

Well, there we are. We have are super duper veriables! (Ok, I wont say that again) Time for two simple camera commands, that you already know! They are 'Position Camera *x,*y,*z' and 'Point Camera *x,*y,*z'!
For position camera, replace the '*x' with 'posx#' and the '*z' with 'posz#'. And replace the '*y' with 'object position y(1)+6' so we are higher than the characters eyes.
On to Point camera, replace the '*y' with 'object position y(1)+6' so we are looking higher than the characters eyes' line of sight. Finally, replace the '*x' with 'object position x(1)' and the '*z' with 'object position z(1)'. Your camera code should look like this:

posx#=cos(270-a#) * 30 + object position x(1)
posz#=sin(270-a#) * 30 + object position z(1)
Position Camera posx#,object position y(1)+6,posz#
Point Camera object position x(1),object position y(1)+6,object position z(1)

*YOU can change the 30 in the two variables to change hor far in and out you zoom. But always keep them the same as each other!*

And here is you final code:
Sync On : Sync Rate 0
Do
if Button(20,55,"New Game")=1 then Goto New_Game
Button(20,95,"Load Game")
If Button(20,135,"Exit")=1 then End
sync
loop

New_Game:
cls
Repeat
Text 240,220,"Get Ready to Play";
sync
Until scancode()>0
make object box 1,4,3,5
make matrix 1,200,200,5,5
Position Matrix 1,-100,0,-100
Do

If Upkey()=1
Move Object 1,2
endif
If Downkey()=1
Move Object 1,-2
endif
If Leftkey()=1
Dec a#,2
endif
If Rightkey()=1
Inc a#,2
endif
yrotate object 1,a#

posx#=cos(270-a#) * 30 + object position x(1)
posz#=sin(270-a#) * 30 + object position z(1)
Position Camera posx#,object position y(1)+6,posz#
Point Camera object position x(1),object position y(1)+6,object position z(1)

sync
Loop
end

function Button(x1,y1,WORDS$)
Pressed=0
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1,y1,WORDS$
endfunction pressed




----------------------------------------------------------------------

*Tutorial 14 - Timer Based Movements
I bet you're thinking "What the heck is this" ? Well, skipping this tutorial is a bad idea- this tutorial is focusing on the performance of your games.

The 'timer()' function that is in DBPro is a function that gets the time in DBPro's time format. Its always changing depending on the time.

Timer Based Movements is a system that uses the 'timer()' function in DBPro to get speeds for your players to move. You're thinking, "Well whats the point? I can just put any number!" But you're wrong. Say you move your player around the world at a speed of 5. Its perfect on your computer. But on someone else's better computer computer, a speed of 5 could be like 20. That would be bad. Everything would be too hard to control.

Now, performance is different depending on your computer. But there is always one thing that you can rely on to be the same. And yeah, its the time. Thats why people use Timer Based Movements. It'll be about the same speed on every computer. Now let's start.

Here is the full code from the last tutorial:

Sync On : Sync Rate 0
Do
if Button(20,55,"New Game")=1 then Goto New_Game
Button(20,95,"Load Game")
If Button(20,135,"Exit")=1 then End
sync
loop

New_Game:
cls
Repeat
Text 240,220,"Get Ready to Play";
sync
Until scancode()>0
make object box 1,4,3,5
make matrix 1,200,200,5,5
Position Matrix 1,-100,0,-100
Do

If Upkey()=1
Move Object 1,2
endif
If Downkey()=1
Move Object 1,-2
endif
If Leftkey()=1
Turn Object Left 1,2
endif
If Rightkey()=1
Turn Object Right 1,2
endif

Point Camera object position x(1),object position y(1),object position z(1)

sync
Loop
end

function Button(x1,y1,WORDS$)
Pressed=0
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1,y1,WORDS$
endfunction pressed




I'm going to use an example from my good friend Cash Curtis.
Now, we have to use variables to contain the speed. This way, it can change. Variables change, get it... the root word is 'vary' which means change

So above the 'Do' command in your 'Do-Loop', post this:
movespeed = 75
turnspeed = 87.5
time=timer()

'Movespeed' is the speed your player will move at.
'Turnpeed' is the speed your player will turn at.
'time' is the variable containing the number received from the 'timer()' function I talked about. Ok, we are almost done.



After the 'Do', put this code:
gameTime=timer()-time
MSframe#=gameTime*(movespeed/1000.0)
TSframe#=gameTime*(turnspeed/1000.0)

Now, we are defining a new variable; 'gametime'. Thats the elapsed time between 'before we started the game' and 'the current time'.

The next two are the actual speeds we find out by doing a little math. 'MSframe#' stands for 'move speed frame'. The same goes for 'TSframe#', except its 'turn speed frame'.


Ok, only 2 more steps.

The first one, is changing your speed values to the variables we declared. Replace your movement code with the following:
If Upkey()=1
Move Object 1,MSframe#
endif
If Downkey()=1
Move Object 1,-MSframe#
endif
If Leftkey()=1
Dec a#,TSframe#
endif
If Rightkey()=1
Inc a#,TSframe#
endif
yrotate object 1,a#



As you can see, all I did is replace the speeds with the variables. Easy stuff



The last step (finally), is re-defining the timer variable. Put this right before the 'sync' in your do-loop:
time=timer()




Wa-la... there you have it. You have Timer Based Movements. Adjust the speeds in the variables we declared before the 'DO' to change speed.

Your final code should be:
Sync On : Sync Rate 0
Do
if Button(20,55,"New Game")=1 then Goto New_Game
Button(20,95,"Load Game")
If Button(20,135,"Exit")=1 then End
sync
loop

New_Game:
cls
Repeat
Text 240,220,"Get Ready to Play";
sync
Until scancode()>0
make object box 1,4,3,5
make matrix 1,200,200,5,5
Position Matrix 1,-100,0,-100

movespeed = 75
turnspeed = 87.5
time=timer()

Do

gameTime=timer()-time
MSframe#=gameTime*(movespeed/1000.0)
TSframe#=gameTime*(turnspeed/1000.0)

If Upkey()=1
Move Object 1,MSframe#
endif
If Downkey()=1
Move Object 1,-MSframe#
endif
If Leftkey()=1
Dec a#,TSframe#
endif
If Rightkey()=1
Inc a#,TSframe#
endif
yrotate object 1,a#

posx#=cos(270-a#) * 30 + object position x(1)
posz#=sin(270-a#) * 30 + object position z(1)
Position Camera posx#,object position y(1)+6,posz#
Point Camera object position x(1),object position y(1)+6,object position z(1)


time=timer()


sync
Loop
end

function Button(x1,y1,WORDS$)
Pressed=0
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1,y1,WORDS$
endfunction pressed





This is all of this tutorial so far.. what do you think about my progress?


Specters
19
Years of Service
User Offline
Joined: 30th Sep 2005
Location: idaho
Posted: 4th Nov 2005 22:01
Not bad at all. Make this a sticky mods.

new site : sealgames.tk
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 4th Nov 2005 22:06
No no no, no sitcky yet. Unless they want to

I am modelling for a freind right now, so more progress will come a little later. Its gonna be a heck of alot of tutorials though.
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 4th Nov 2005 22:14
FIRST THING!!!!!!!!!!!
Buy yourself some books and write down all the ways you can make it..or else you will find yourself having frequent coders block >_>

Making better games everday!
Oh yeah and just so you know its Oh-nek-a not One-ka!
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 4th Nov 2005 22:17
I've gotten it written down in my mind completely. Dont worry, I am in the process of making an RPG so I can still go back in reference to how I made my RPG.
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 4th Nov 2005 22:37
Why not compile this into PDF using my tutorial compiler!

WE SHALL BECOME ALL POWERFUL! CRUSH THE LESSER RACES! CONQUER THE GALAXY! UNIMAGINABLE POWER! UNLIMITED RICE PUDDING ! ! ! ETC. ! ! ! ETC.! ! !
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 4th Nov 2005 22:40
Haha, thanks for the offer. I'll look into it, but first let me finish these models!
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 4th Nov 2005 23:37 Edited at: 4th Nov 2005 23:51
Alright, I'm done the modelling and made two animations, now back to work

EDIT: I'm done Tutorial 6 .
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 5th Nov 2005 01:05
I'm done 7 now too.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 5th Nov 2005 01:49 Edited at: 5th Nov 2005 02:10
Quote: "So lets get our first variable, shall we?

How about health - to store health, it will be a numeric value. For a variable, all numeric value variables should end with a ' # ' . For example, health would be not be stated as ' health ' in the code, but as ' health# ' . To assign the variable a value, its probobly exactly what you thought. It would look like this:
health# = 100
Now health doesn't have to be 100, but its a reasonable amount. When you compile the program, the program will not say ' 100 ', because we didn't make it do that. And thats exactly what we are gonna do next."


It looks good but there's one problem. The # sign does not mean it's a number. It's actually a real number. A real number is a number with a decimal point... so if you add .1 it'll keep that .1 to the number. You only use real numbers for anything that might potentially need a decimal point such as the coordinates of a 3D object.

Numbers that do not need decimal points like the HP of a character do not need the # symbol because you'll never want to do .1 to .9 damage to the character.

I quote the Darkbasic Help Files (this is from the first page in the PRINCIPLES menu, Datatypes And Variables):
Quote: "
Integer Numbers

An integer number can hold a whole number, but no fraction. For the value to be negative, you must place a hyphen symbol (-) before the value. You must not use commas as part of the number as this would generate a Syntax Error. Examples of integer numbers:

42
10000
-233000
-100


Real Numbers

A real number can hold a whole number or a fractional number that uses a decimal point. For the value to be negative, you must place a hyphen symbol (-) before the value. Examples of real numbers:

20.0005
99.9
-5000.12
-9999.9991


So far, we have seen variables used to store and recall integer values. Variables can also store real numbers and strings. In order to allow a variable to store these other types of data, you must make sure the variable is recognized as an integer, real or string variable. To name a real number variable, you must add a hash character (#) as the last character of the variable name. If you want your variable to store a string, you must add a dollar character ($) as the last character of the variable name. Let's see these new variables used to store and recall real values:

mydata#=42.5
PRINT mydata#

By adding the (#) symbol, we are instructing the program to treat the variable as a real number variable.
"


Don't feel bad about this mistake. A lot of people (even many non-newbies) have trouble with the difference between a whole number (with no # sign) and a real number (with a # sign) simply because they both work relatively the same. The bottom line... if the number you want will always be a whole number... don't use # when you define it.

Using whole numbers makes the code run faster too... I heard that from TDK so you know it's right.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 5th Nov 2005 04:02
Lol, I knew this fact Grog, but it got me confused in the beginning, so I'm saving the confusion of the others

I g2g now, need some sleep, will be back tomorrow for more!
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 5th Nov 2005 04:51 Edited at: 5th Nov 2005 04:51
Quote: "Lol, I knew this fact Grog, but it got me confused in the beginning, so I'm saving the confusion of the others

I g2g now, need some sleep, will be back tomorrow for more! "


Ah ok... as long as you know.

Oh... and please don't say "the others" again... I watch Lost... hearing that gives me chills.

http://abc.go.com/primetime/lost/index.html
Darkbasic MADPSP
19
Years of Service
User Offline
Joined: 15th Jun 2005
Location: Uk
Posted: 5th Nov 2005 10:11
What was wrong with mine?

Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 5th Nov 2005 11:10
Quote: "What was wrong with mine?"


Try and find something right with it! You are not really proficiant enough with DBP to be writing tutorials. I know you are only trying to help but most of the 'help' you offer is wrong.

I suggest you stick to reading tutorials (like this one) rather that trying to write them.


Great Britain would be Amazing Britain if it wasn't for idiots like you bringing down the average!
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 5th Nov 2005 11:12
DarkBasic MAD,

(It might sound cruel)
It was a failed attempt on a tutorial. You're making alot of mistakes. How can a beginner learn from a tutorial when it learns you to make mistakes? Also, you're not actually explaining your code. You say this does this and then display 10 lines of code. How do we know what lines does what?

Again, no offence.

Xenoscythe,

Nice tutorial. It starts from the very basics. I think many beginners will look forward to the next part of the tutorial.

Immunity and Annihalation makes Immunihalation...
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 5th Nov 2005 14:29
Thanks everyone , and DB Mad, keep practicing, maybe you can learn something from here!

Lads, I've finished the Long tutorial 8!!!
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 5th Nov 2005 14:30
Quote: "Lol, I knew this fact Grog, but it got me confused in the beginning, so I'm saving the confusion of the others

I g2g now, need some sleep, will be back tomorrow for more! "


That's nice, but instead of teaching newbies one thing why don't you teach them the real way and then if they decide they don't want to do it the real way then they can change how they do it. It doesn't seem very fair to not even explain why you are using # when you know it isn't the real way to do it.

Quote: "The # sign does not mean it's a number. It's actually a real number"


Actually the conventional term is float. If you try and say number# as real, the compiler will freak out because it has no documented real data type.

Quote: "Oh... and please don't say "the others" again... I watch Lost... hearing that gives me chills."


Agreed.

Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 5th Nov 2005 14:32
Antidote, you have to understand.. How many people learned the word 'float' in DB right off the spot? I think it confuses them, so just let it be until later in the tutorials, k?
Sergey K
20
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 5th Nov 2005 15:36 Edited at: 5th Nov 2005 15:37
Quote: "health#=100
"


erm i thikn if u using float, it should b something like that: health# = 100.0
but if u want to remove the .0, u just have to use the variable without "#" like health = 100 << good and simple.

u also can define the variables like u want..
use:
health as float
health = 100.0

the "#" is a shortcut for float..


BlueLight Online, improved version of MorningOnline
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Nov 2005 00:17
Quote: "Actually the conventional term is float. If you try and say number# as real, the compiler will freak out because it has no documented real data type. "


True.
Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 6th Nov 2005 06:22
I got to agree with Antidote here, # = float. you need to learn that immediatly, confusing data types is a core problem, you NEED to understand what symbles mean what asap.

There is no reason WHY health has to be anything other than an integer usually, unless you are planning something funky. I think making it a float adds to the confusion and then not explaining what a float is just adds salt to the wound Later on in programming with complex math use the wrong data type and you get a completly different result.

Or say a check like if health = 0 can sometimes fail because it's 0.0345 or something strange, really would be ebst to use an integer

Good tutorial though, just personally think a small paragraph or two on data types isnt a bad idea.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Nov 2005 08:28 Edited at: 6th Nov 2005 08:36
Quote: "I got to agree with Antidote here, # = float. you need to learn that immediatly, confusing data types is a core problem, you NEED to understand what symbles mean what asap."


I hope you don't include me in that because I called it real instead of float. My only defense is that's what it's called in the Darkbasic help files.

To me because I looked at the Darkbasic help files I consider both "real" (when talking) and "float" (in code) to mean a number with a decimial point and that uses the # sign (in code).
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 6th Nov 2005 15:37
Quote: "Antidote, you have to understand.. How many people learned the word 'float' in DB right off the spot? I think it confuses them, so just let it be until later in the tutorials, k?"


I learned on the spot and it doesn't confuse anyone. Also that is a fundamental. I thought the purpose of a fundamental is that it is taught in the beginning so it can be applied later on in programming.

Quote: "To me because I looked at the Darkbasic help files I consider both "real" (when talking) and "float" (in code) to mean a number with a decimial point and that uses the # sign (in code)."


Same here because I took a class on Pascal last year. However, it's probably a better idea to refer to them as floats since most of the programming world refers to them as floats and not reals.

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 6th Nov 2005 15:57
'Reals' and 'Floats' to me are interchangable terms for the same thing. What you refer to them as depends on what other programming languages you use (if any).

For example, in Delphi, Fortran, and C++, decimal point variables are 'Reals' - not 'Floats'.

The main point is that you only use real variables when you need them as integer variables are much faster in calculations.

TDK_Man

Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 6th Nov 2005 16:45
In this case you may call them reals or floats I will call them floats because i'm a c++ programmer and theres two types of real number for us, a float and a double - a double is the same as a float except it has a higher level of accuracy (more numbers after the decimal point) but takes twice the size. So im just used to specifying exactally what type of "real" number im talkng about

I'm pretty sure the default real type for dbp is a float.

Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 6th Nov 2005 20:00
[quote]For example, in Delphi, Fortran, and C++, decimal point variables are 'Reals' - not 'Floats'.[/qoute]

No, C++ decimal values are floats and doubles

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 6th Nov 2005 21:20
Quote: "No, C++ decimal values are floats and doubles"


Yes sorry - I stand corrected.

It's a long time since I did any C++ programming so I did a quick search on the net to check before I posted. I just happened to choose a web page which compared C++ to Pascal and I was reading the wrong bit!

Having read it again but properly this time, I agree with you - they are Floats in C++!

Oops...

TDK_Man

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 7th Nov 2005 05:29
I've only programmed in Basic, GWBasic, Quickbasic, and a little bit of C++ before I was told about Darkbasic... i've only seen "real" in Darkbasic. Really the help files need to be changed to only use "float" since that's what we use for UDT's.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 7th Nov 2005 22:05
8,9, and 10 completed!
Do you think I should change my tutorial for the 'float' thing, or just explain it later in the tutorial?
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 7th Nov 2005 23:15
Change it definetly. It may seem like a lot of work but it's going to be a lot more trying to explain it later on.

Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 8th Nov 2005 22:45
Well I changed it to float, did anyone find this tutorial useful so far?
x1b
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location:
Posted: 8th Nov 2005 23:57 Edited at: 9th Nov 2005 00:07
I like it Xeno. Keep on it man. I check frequently for updates on it. Maybe later on you and I could write a tut on advanced rpg development. My WIP is ment to be OpenSOurce to start with, so can use alot of source from it as examples. I'm on a learninf curve my self w/ LIT pretty much my unoffical mentor.


[edit]
I took the time to read it all and noticed that you assume nothing of the reader. Awsome. It will save alot of confusion and question by not assuming anything of your readers.

- Do it, Do it Right, Do it right now..
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 9th Nov 2005 00:18
Heh, thanks man. I'm glad you feel that way about it.
x1b
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location:
Posted: 9th Nov 2005 00:27 Edited at: 9th Nov 2005 00:35
You really should have placed a Tutorial on a combat system after the health. Health serves little purpose if there is no means to lose it

The use of "wait" for a time isnt always wise as was explained to me by LIT. wait, Can/will cause alot of disruption in the game or just all together pause the whole thing. You may want to explain how to code a time() function. Something like what I had to do for my jump in my WIP.

- Do it, Do it Right, Do it right now..
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 9th Nov 2005 00:29
Hehe dude, you forgetting that they just bought DB, and this is the EXTREME basics

I will add all that later because that is more advanced then making a menu for your game
Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 9th Nov 2005 00:33
its good that you called the variable a float, but im still not sure why you are using a float for health you only need to use floats if you require a decimal point, health should probably be an integer

Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 9th Nov 2005 01:21
hehe, i know it's been hashed and re-hased here but just wanted to say that the term "real" is more of a mathmatician's term... meaning any number on the number line... ("integer" is only the numbers that "have no decimal places")

and of course there are "rational" (can be displayed as a fraction, or a finite amount of numbers) and "irrational" (can't be displayed as a fraction, and uses a infinite amount of numbers)

anyway, great tutorial!

"We make the worst games in the universe."

x1b
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location:
Posted: 9th Nov 2005 03:12 Edited at: 9th Nov 2005 03:32
Quote: "Hehe dude, you forgetting that they just bought DB, and this is the EXTREME basics"


I can respect that, however, it is considerabley redundant to teach a incorrect approach then undo what was taught and finally teach a correct approach.

I by no means mean to disprespect you, Xeno, nore do I mean to hijack your thread by doing the following. I am only doing what this forum has done for me, time and time again.

time() isnt so advanced nore as daunting as one may think,as LIT had taught me.

Allow me to explain in a manner easy to follow:

begin:

Zoogan the Terrible(a character used in my rpg wip),after having had a brutal and fatal confrontation with Sir Player Character and having releived the arrogant pratt of his fat head from his now limp and lifeless body,has him self taken a near fatal blow and requires rest to heal his wounds..



And so we have it, the not so daunting task of using the time() function in our RPG Engines!

- Do it, Do it Right, Do it right now..
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 9th Nov 2005 07:49
Quote: "its good that you called the variable a float, but im still not sure why you are using a float for health you only need to use floats if you require a decimal point, health should probably be an integer "


I'm with you, Sephnroth. If the player health will never be a number with a decimal point... remove the # from "Health#". All it does is teach newbies to use floats at inappropriate times. Also telling newbies that it's a "float" without explaining what "float" means is just as bad (even though they can get that from reading the rest of the messages in this thread).
x1b
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location:
Posted: 9th Nov 2005 12:21 Edited at: 9th Nov 2005 12:41
I suppose,it would be possible to require a float for such a variables as "health" in the scenerio of a duration effect such as "potions","spells" etc and stack effects.

- Do it, Do it Right, Do it right now..
Drew Cameron
20
Years of Service
User Offline
Joined: 30th Jan 2004
Location: Scotland
Posted: 9th Nov 2005 23:26 Edited at: 9th Nov 2005 23:28
Firstly, this is looking great Xenocythe - it's really helpful for anybody just starting out and I look foward to seeing it expand with time!

And secondly, to everyone arguing about floats and real numbers and "telling him off" or whatever - who cares? Really, FFS, who cares? Why don't you post about what was good with the tutorial and not nitpick.

Again, a really helpful start Xenocythe! I would perhaps look into code boxes, or as Mnemonix said, some kind of .PDF might be good?

Keep it up though.

Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 10th Nov 2005 03:09
Ummm. Floats and all that are very important. Also he said he'd rather not tell them about the difference between floats and integers. That is a little more harmful to newcomer's than telling them the correct thing to do. I'm not saying this isn't a good tutorial. I just pointed out a flaw. I did the same thing to Ruccus on his FPS tut.

x1b
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location:
Posted: 10th Nov 2005 03:21
It's really not that big a deal. At worst, he goes back, corrects that part of the tutorial, thanks whom ever for pointing it out and moves along.

- Do it, Do it Right, Do it right now..
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 10th Nov 2005 17:49
Quote: "It's really not that big a deal. At worst, he goes back, corrects that part of the tutorial, thanks whom ever for pointing it out and moves along.


- Do it, Do it Right, Do it right now.."



Your sig is ironic with what you just said

x1b
20
Years of Service
User Offline
Joined: 19th Sep 2004
Location:
Posted: 10th Nov 2005 21:45 Edited at: 10th Nov 2005 22:02
Look, we all took turns reeming the poor guy. it's "Do it, Do it right, Do it right now.." not "Do it, Do it right, Do it right now or i'm going to throw a complete fit for days, spam you to death about it and make a general ass of my self"


I think we made our point. Let him continue or adjust his tutorial.

- Do it, Do it Right, Do it right now..
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 19th Nov 2005 01:03
Wooh! I'm done the 11'th tutorial, which starts you off with 3D !

So far this tutorial is compatible with DBC and DBPro...

(I wish this would become a sticky...)

Frozen Flame
20
Years of Service
User Offline
Joined: 22nd Jul 2004
Location:
Posted: 2nd Jan 2006 07:22
Hey Xenocythe nice tutorials.
I see the thread has kinda dropped.. but i wanted to remind you about the Galekus thread you made. Do you think you could put the tut in a single file (or multiple files for diffrent tutorials) and submit them to my site? Would be a great addition. Cya around.. hopefully at Galekus


Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 2nd Jan 2006 18:07
I probably would have if I completed these... I mean does anyone find these tutorials helpful? Any body want me to keep writing them? It actually seems like no one cares, I mean is anyone benifitting from these tutorials? If so, please tell me and I'll continue them. As a matter of fact, I'll continue them If I get 5 votes to continue them and how it benifitted them, because I dont want to spend my time making tutorials that nobody reads.
Thanks!
Medieval Coder
18
Years of Service
User Offline
Joined: 31st Dec 2005
Location:
Posted: 2nd Jan 2006 18:24
Awesome this is gonna help me so much!
Medieval Coder
18
Years of Service
User Offline
Joined: 31st Dec 2005
Location:
Posted: 2nd Jan 2006 18:43
Hey...ive got a problem...
Whenever the program gets to Wait 3000 it leaves and goes back to the "notepad type thing" that i wrote the code in..... any suggestions?
Also when i type in wait key instead of Wait 3000, then press a button (spacebar) it leaves the "program"

Here is the code for the Wait 3000

Login to post a reply

Server time is: 2024-11-24 06:40:09
Your offset time is: 2024-11-24 06:40:09