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 / Total noob

Author
Message
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 12th Aug 2006 02:57
Hi,
Iv'e just started DarkBASIC and decided that 2D was the best place to start(Please comment if i'm wrong) now that I've decided that i'm going to do 2D, I would like to know some of the basics like about Sprites and 2D animation. No one has to write me a tutorial if they don't want to( I've heard people hate noobs that ask for alot) I just need to some basics.

Cocacola and Pepsi aren't that differnt. Deal with it.
Big Man
19
Years of Service
User Offline
Joined: 4th Feb 2005
Location: BEHIND YOU!!!! (but I live in England)
Posted: 12th Aug 2006 19:47
ok what exactly do you want i can tell you a lot about 2d but am unsure where to start.

what about simply making a sprite and moving it around the screen?

BM

Our aim is to keep the loo's clean, your aim can help.

3.0ghz pentium dual core processor, 2gb ds ram, 250gb HD
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 12th Aug 2006 22:02
Quote: "Originally posted by Big Man
what about simply making a sprite and moving it around the screen?"



That would be a great place to start

Cocacola and Pepsi aren't that differnt. Deal with it.
Big Man
19
Years of Service
User Offline
Joined: 4th Feb 2005
Location: BEHIND YOU!!!! (but I live in England)
Posted: 12th Aug 2006 23:27
ok then.

Here is your first bit of code (note this doesnt work its for explanation purposes only



what this does is load an image and create a sprite out of it. You may notice 4 numbers after sprite here are what they do:
First number (1) : This is the number you call your sprite
second number (x) : this is a variable called x and it is use to set the x coordinate of the sprite
third number (y) : same as second exept it sets the y coordinate
fourth number (1) : This is the image number you are using for the sprite.

If using db pro you might want to pu this before the load image comand.



this gets rid of the nasty blue screen associated with the sprite (if using classic dont use it you dont need to)

next this code snippet includes the previouse code aswell.



Ok you may have noticed that i moved the sprite command line into the main loop and added the set sprite command

What this all does

Before teh load image command i have put x=10 & y=10 these variables are read by the sprite command and lets it know where to put the sprite.

this chunk of code



basically tells dark basic to increase the x &y variables which in turn moves the sprite coordinates.

the set sprite comand has three numbers after it and this is what they do.

number one (1) : this is the sprite number
number two (1) : this is the backsave state i'll explain later.
number three (1) : when set to 1 it tells db that black is a transparent colour

backsave

When set to one this tells db to delete teh sprite every time it moves and repaste it so you dont get a nasty tail of sprites.

compile the second code to see what it does. Remeber to load an image that is already in the saem folder as your project.

Please ask if you need any more help

Cheers
BM

Our aim is to keep the loo's clean, your aim can help.

3.0ghz pentium dual core processor, 2gb ds ram, 250gb HD
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 12th Aug 2006 23:50
Thanks for replying
I have another question though, how do I create the image? should I just draw one in photoshop?

Cocacola and Pepsi aren't that differnt. Deal with it.
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 13th Aug 2006 01:35
see down load:

Attachments

Login to view attachments
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 13th Aug 2006 01:51
Thanks for the tutorial and all,but I was askng about making the image for the sprite, like should I use a special program?, or should I make it a special way?

Cocacola and Pepsi aren't that differnt. Deal with it.
Big Man
19
Years of Service
User Offline
Joined: 4th Feb 2005
Location: BEHIND YOU!!!! (but I live in England)
Posted: 13th Aug 2006 17:57
no just make it in MS paint.

Then save it in the same folder as your dark basic project (source code) and load the image using.

Load image "image_name.bmp",1

hope this helps

BM

Our aim is to keep the loo's clean, your aim can help.

3.0ghz pentium dual core processor, 2gb ds ram, 250gb HD
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 13th Aug 2006 18:12
Does Photoshop 7 work equaly as well?, and if it does how do I get rid of the white backround behind my image?

Cocacola and Pepsi aren't that differnt. Deal with it.
Big Man
19
Years of Service
User Offline
Joined: 4th Feb 2005
Location: BEHIND YOU!!!! (but I live in England)
Posted: 13th Aug 2006 18:35
yep Photoshop sounds good.

Tip the background black remember the set sprite command i told you about look at my second post 3/4 of the way down.

BM

Our aim is to keep the loo's clean, your aim can help.

3.0ghz pentium dual core processor, 2gb ds ram, 250gb HD
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 13th Aug 2006 19:09
Thanks I made a quick sprite and changed the backround to black and now I can move him around the screen. I do have another question though, now that I made a sprite how do i make animation for walking and stuff, and play the animation when you press the controls?

Cocacola and Pepsi aren't that differnt. Deal with it.
Big Man
19
Years of Service
User Offline
Joined: 4th Feb 2005
Location: BEHIND YOU!!!! (but I live in England)
Posted: 13th Aug 2006 19:30
you need to use the get image comand but i am not very good with it I havent yet used it in any of my projects.

There is another way buti've got to go and I will tell you later.

Cheers

BM

Our aim is to keep the loo's clean, your aim can help.

3.0ghz pentium dual core processor, 2gb ds ram, 250gb HD
NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 13th Aug 2006 21:43
You don't need to use get image! That would do nothing but kill the Frames Per Second!


Since the other one was scaring you guys so much...
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 13th Aug 2006 22:06
So how do you do it?

Cocacola and Pepsi aren't that differnt. Deal with it.
Big Man
19
Years of Service
User Offline
Joined: 4th Feb 2005
Location: BEHIND YOU!!!! (but I live in England)
Posted: 14th Aug 2006 12:52
Ill write up a tut later but I have just woken up so give us a minuite.

Cheers

BM

Our aim is to keep the loo's clean, your aim can help.

3.0ghz pentium dual core processor, 2gb ds ram, 250gb HD
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 14th Aug 2006 19:02
Thanks:

Cocacola and Pepsi aren't that differnt. Deal with it.
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 17th Aug 2006 02:58
um... BigMan, it's been two days and I'm not sure if you are going to reply with the tutorial. If you do not want to post one it is ok seeing how I searched the forums and figured out myself how to do it. if you still wish to offer help, I'm perticuarly stuck on 2D Grid Making ,and A* pathfinding. if you know anything about that, please reply.

Cocacola and Pepsi aren't that differnt. Deal with it.
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 17th Aug 2006 07:03
game design, time to think about arrays.

imagine your game grid is 10 x 10 in size.
draw it on a piece of paper for clarity.

Now think of the across rows as the X dimension. ( to remember easier the X is two arrows pointing left and right)
think of the down columns as the Y dimension. ( the Y is an arrow pointing down and the opposite is up)


when you define an array it can be 1 dimension or 2/3/4/5
we are only thinking about a 2 dimensional one in this example.

arrays usually start from zero and upwards, for sanity and a little lost memory we will define the array starting at one.

lets make an array with one dimension to start with.



this makes an array of 1 dimension with 11 spaces. The zero pocket is counted as well.

0 1 2 3 4 5 6 7 8 9 10

Think of an egg carton with one row of 11 eggs.
each egg is your data, the carton is the array.

there is no data in each pocket so each location should represent zero.
if we want to populate this array with data we can fill it up manually.
myarray(0) = 0
myarray(1) = 1
myarray(2) = 2
etc..

that can get a little long winded so we deploy a loop




notice we didnt fill the first pocket with any data, it just helps to make it easier to manage.
otherwise myarray(0) could be 1 and therefore every valuable is one behind in the list.

we can easily print out the data as well by adding a print statement to your loop



we are taking the result of c and doubling it for the data.
you can do anything here you like eg: c +5 would start the array data at 6 7 8 9 etc..

It should print something like this.

my array location :1 = 2
my array location :2 = 4
my array location :3 = 6
my array location :4 = 8

etc..


the variable c keeps going up to 10, the STR$() command just converts the numerals to textual data for use in the print statement.

now lets go back to the 2 dimensional array idea and create one and populate it with random numbers in each of the array locations, without filling the zero locations for clarity.




we have just filled the array in both X and Y dimensions with random numbers from one to ten.
naturally if we want it to be truely random we have to add a small line at the top of the program



this command basically takes what time it is and seeds the randomize command with a starting number providing a good method to get a random result.


your challenge today is to add a command to above snippet that will print out the data to the screen. look at my first 1 dimensional array for a clue.



There is a lot more to learn about arrays but give them a go before you embark on things like A* path finding and you will find it a lot easier to read other examples.

arrays can be a godsend for game maps and well worth your learning.


when you want to destroy an array you would use the undim command.


This is best used at the end of your game when cleaning up.


Pretty soon you will get the hang of things, down the track it will get a lot easier in some ways.
just start slowly and dont skip stuff.

Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 17th Aug 2006 19:39
Thanks

Cocacola and Pepsi aren't that differnt. Deal with it.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 17th Aug 2006 20:36 Edited at: 17th Aug 2006 20:39
Another array tutorial I wrote: Hello.


Big Man
19
Years of Service
User Offline
Joined: 4th Feb 2005
Location: BEHIND YOU!!!! (but I live in England)
Posted: 19th Aug 2006 15:52
Im really sorry Gamedesign er20 i got confused when this thread was moved.

Plus i have been at work for the past few days and have had no time to do anything.

BM

Our aim is to keep the loo's clean, your aim can help.

3.0ghz pentium dual core processor, 2gb ds ram, 250gb HD
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 19th Aug 2006 19:41
It's ok, I really didn't know that the thread was moved either, I wonder why it happend?

Cocacola and Pepsi aren't that differnt. Deal with it.
Big Man
19
Years of Service
User Offline
Joined: 4th Feb 2005
Location: BEHIND YOU!!!! (but I live in England)
Posted: 19th Aug 2006 20:45
it was moved cause it was off topic for the 2d board and fitted better in this board.

Do you still need my help?

BM

Our aim is to keep the loo's clean, your aim can help.

3.0ghz pentium dual core processor, 2gb ds ram, 250gb HD
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 19th Aug 2006 22:19
Well I think I got the hang of animating sprites and now i'm pretty much just still wondering about A.I. for my PacMan like game(It's not actually PacMan, just a game that's like it)
if you have ever played PacMan and know how they made that type of A.I. for the ghosts, I would appreciate the help, if not than I thank you for all the help you gave me earlier.

Cocacola and Pepsi aren't that differnt. Deal with it.
Jerok
19
Years of Service
User Offline
Joined: 7th May 2005
Location: Mars. Wait a sec I\'m on MARS. OMG
Posted: 19th Aug 2006 22:54
for PacMan ai you could try looking at the pacman tutorial(you might have to search around the forums some)

another suggestion i have for 2d stuff is if you look at the top of the 2d forum at the stickies there are some really great tutorials made by reaperman(i think) that you could try. i would reccomend finishing your pacman game first though as they might get a little complicated if you try to do them right away
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 20th Aug 2006 01:14
I already have the PacMan tutorial but I have DBC not DBPro which is what the tutorial is for. Unless i was able to convert the DBPro
codes to DBC, I don't think that will work.

Cocacola and Pepsi aren't that differnt. Deal with it.
Jerok
19
Years of Service
User Offline
Joined: 7th May 2005
Location: Mars. Wait a sec I\'m on MARS. OMG
Posted: 20th Aug 2006 01:41
i cant help much with dbc sorry ive always used dbpro
Gamedesign er20
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 20th Aug 2006 02:21
It's ok, I can't expect everyone to use DBC.

Cocacola and Pepsi aren't that differnt. Deal with it.
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 22nd Aug 2006 06:49
sorry guys, i moved it as its more newcomer material

Login to post a reply

Server time is: 2024-11-27 09:42:52
Your offset time is: 2024-11-27 09:42:52