#Some Guy's 2D Tutorial For DBC# **Skill Level: Beginner**
#############################
# Contents #
#############################
Chapter 1: Introduction and Pong
Chapter 2: Making a Break-Out Clone
Chapter 3: Making a Space Invader Clone
Chapter 4: Making a Defender Clone
Chapter 5: Making a Duck Hunt Clone
Chapter 6: A most awesome Pac-Man Clone
Chapter 7: Ratty a puzzle game (kinda)
Chapter 8: Boxing Knock-Out
Chapter 9: Tile-Master
Chapter 10: Character-Master
Chapter 11: A Mario Clone
Chapter 12: Yes it's a Final Fantasy Clone or Zelda Whatever You Want!
################################################################################
Chapter 1: Introduction and Pong
################################################################################
Section 1.A - The Introduction
###############################################################################
Welcome to my most awesome 2D Tutorial, I'm not very modest am I? Anyways, lots of people
start out with DarkBASIC (Classic) thinking that they're gonna make a great 3D Game in whatever
genre. They're told to start small and make text games or pong whatever, then what then? What's
after the beginning? Most tutorials on the TGC forums (no offense) are vague, or more geared
towards an abousulte noob. Or not done at all, or else they die out. These tutorials will have a
beginner section don't worry, and at the end you will hopefully be a little better and do 2D games
better. You won't be an expert programmer, or 2D Master. It takes years to program and be
consider above noob status. This makes alot of people angry, but it's true at least you can be
happy that you don't have to program C++/C or Direct X SDK. This takes lots of work and quite
frankly it's geared for expert programmers. At least from what I heard, in the old days of
programming they used Assembly. Oh that's easy you say, no it's hard Assembly uses
commands like POP, etc. Before Direct X there was DOS games were made for, engines need
to be made when you work with C. Several thousand lines of code later, and a flaming keyboard
later your hands are sore and bleeding. Guess what you're just done with the engine, or you can
buy one that takes thousands of dollars. So, let's be happy with DBC and save C++ when we
make our own blockbuster game that is the true halo-killer. So that's why commerical games take
longer.
Your First Assignment - Check out some DBC games in the TGC Showcase under DBC.
Man, I wish I had that assignment before in school!
This Ends Section 1.A
################################################################################
Section 1.B - Tips and Hints On Posting On the TGC Forums
################################################################################
Some newcomers sometimes post things that may attract a flamer. Or as I can them bullies,
this results in hurt feelings and the average flamer feeling good about themselves because they
just insulted a human being with real feelings not a robot.
***You can skip this if you'd like***
Team Requests: Don't post any team requests period, unless you got a big bag full of info about
your game, games you made, a demo, source code, etc.
Game Accounments: Unless you have a screenshot, and later a demo don't post anything
dealing with a WIP (Work in progress) post. Make sure you tell about your game, and you could
post code snippets or something if you wish.
Info about your website: One user did this and man did he get flamed! TGC forum users use the
TGC forums.
Flame: Don't flame anybody it can really hurt someones feelings and make them just give up
using the forum.
What does it mean when a thread as a lock on it?: It means no one can post on the thread any
more because it's a really old thread or did not agree to the terms of conditions on TGC Forums.
What does it mean when a thread is red?: It means it a old thread about 30 days old or
something?
I can't see my post!: If your new you posts get checked before they are posted don't worry
it's not because they hate newcomers it's because they seeing if you post garbage like flames
or if you are agreeing to the terms of condition.
What boards should I use?: 2D All The Way, Newcomer Board, and the DBC Board for
newcomers or really whatever you want as long as you agree to the terms of condition.
################################################################################
Section 1.C - 4 Beginners Only
################################################################################
Okay this one's for somebody who just started. By the way try DarkEDIT it's a better editor.
Rem Crazy Lib
Rem A Mad Lib Game By <Instert your name here>
Rem Print prints text on screen, input allows user input
Rem Rem statements are skipped
Rem Variables allow you to store data
Rem string$ = "aaaaa", real# = 1.000232,integer = 12
Rem Input is a blocking command, it gets done first
input "Enter A Male Name> ",name$
input "Enter An Animal> ",animal$
input "Enter A Town> ",town$
input "Enter A Decimal Number> ",decimal#
Input "Enter Your Favorite Number> ",favenum
input "Enter A Plant> ",plant$
input "Your Name> ",yname$
Print "Okay Press Any Key To Clear the screen!"
rem wait key can be used in this situation, you can also use wait timetowait, sleep timetowait,
rem or suspend for key.
wait key
rem cls clears the screen of text and what not
cls
rem now the story
Print "There once was a king named ";name$;" that lived in the kingdom of ";town$
Print "He had a big allergy to ";animal$;"s and ";plant$;"s "
print "So one day his trusty knight ";yname$;" said I'm gonna add ";decimal#;" and ";favenum
Print "Together to find a cure for this allergy"
Print "And the knight did"
Print "Sorry this was short THE END"
wait key
rem end does just that ends the program
end
################################################################################
Section 1.D - Ping a Pong Clone
################################################################################
Ah pong, some say it was the first video game or arcade game for that matter but they're wrong.
Space Wars I think that's what it was called was the first game, it was too hard for the general
public since no one played a game before. The future founder of Atari I forget his name, tried
he (I think he did) to make a computer version of the first game called Computer Space. After the
company he worked with the same one that made the first game wouldn't agree to pay him extra
he quit and started atari which means go or check mate. Ping-Pong was copyrighted and pong
was the noise the ball made when it impacted so this began Pong. Pong was very successful
no doubt, this ends Video Game History 101, but if you want you can check out
www.classicgaming.com for a history of video games that's told better then how I told it.
It's get to making our game!
You can open up the source code, or you can view the exe file if you wish. I'd like for you to
make it on your own first. Unzip the media and stuff you'll need first before anything happens.
Source Code:
` You can use the ` Sign instead of Rem to shorter things up
` Ping
` The Chapter 1 Tutorial Game
` Setup Display
` Sync tells the computer you will be manually updating the screen
` The sync rate tells the computer how fast to update it when you put in the sync command
sync on
sync rate 40
hide mouse
` Load all the images used as bitmaps, the number at the end is
`The images numeric name
load image "paddle1.bmp",1
load image "paddle2.bmp",2
load image "ball.bmp",3
` Load the music we will be using, the number means the same
` As in the load image command
load music "Dodge This.mid",1
` Load the sound thump
load sound "thump.wav",1
` Play the music we use, which is music 1 or Dodge This
play music 1
` Start the main game loop
` Setup some variables first, all of these variables are integer ` ` ` ` numbers
oneypos = 1
onexpos = 1
twoypos = 1
twoxpos = 620
bally = 150
ballx = 150
movey = rnd(1)
movex = rnd(1)
onegoal = 0
twogoal = 0
do
`HUD or Heads Up Display
`This sets text to write over the other text on the screen
set text opaque
text 1,1,"Goals: "+str$(onegoal)
text 585,1,"Goals: "+str$(twogoal)
` Player 1 Paddle
` This means if the upkey is pressed then we'll move up one space
` Vertically
` The if downkey is pressed we're gonna be doing the opposite move
` Down
` This means if the variable for the paddle's y position oneypos
` Is less the 1 then move it down
` And if it's greater then 432 move it up
if upkey() = 1 then oneypos = oneypos - 7
if downkey() = 1 then oneypos = oneypos + 7
if oneypos < 1 then oneypos = oneypos + 7
if oneypos > 432 then oneypos = oneypos - 7
`The sprite command calls an object to be put on screen
` Sprite spritenum,x,y,imagenum or frame
sprite 1,onexpos,oneypos,1
`Player 2 Paddle
`This is mostly the same as above only with paddle 2.
if inkey$() = "w" then twoypos = twoypos - 7
if inkey$() = "s" then twoypos = twoypos + 7
sprite 2,twoxpos,twoypos,2
if twoypos < 1 then twoypos = twoypos + 7
if twoypos > 432 then twoypos = twoypos - 7
`The Ball
`We use a for next loop to create it's bouncing effect
`Remember movey = rnd(1) and movex = rnd(1)
`This means that you move down if movey is equal to one
`Or up in the case it is equal to 0
`If movex is = to 1 we move across right
` Or if it's equal to zero we move left
if movey = 1 then bally = bally + 5
if movey = 0 then bally = bally - 5
if movex = 1 then ballx = ballx + 5
if movex = 0 then ballx = ballx - 5
sprite 3,ballx,bally,3
`This means if the paddle 1 or 2 is hit the ball will move
if sprite hit(1,3) = 1 then movex = 1:play sound 1
if sprite hit(2,3) = 1 then movex = 0:play sound 1
if ballx < 1 then movex = 1:twogoal = twogoal + 1:play sound 1
if ballx > 620 then movex = 0:onegoal = onegoal + 1:play sound 1
if bally < 1 then movey = 1:play sound 1
if bally > 432 then movey = 0:play sound 1
`Wins
`We use if endif for long conditional statements
`Text can be used instead of print also
` text x,y,string$
if onegoal = 10
text 100,150,"Player 1 Has Won!"
wait 300
end
endif
if twogoal = 10
text 100,150,"Player 2 Has Won!"
wait 300
end
endif
`Refresh the screen
sync
loop
`End of Main Game Loop
Explained:
You use comments in your program to let you know what you were thinking when you
programmed the application.
Here's some examples of comments:
` Setup the display
Rem Blast the Aliens
Remstart
a group of comments started
remend
Sync is used for updating the screen manually
Loops to something until a condition is met such as this
Repeat
Print "HELLO HELLO HELLO!"
until stopprint = 1
While printtext = 1
Print "HI HI HI HI"
endwhile
For a = 1 to 200
print "YO"
next a
do
cls
text mousex(),mousey(),"I'm Following Your Mouse!"
loop
Text
Some find text boring others make text games, I like a text game personally.
Try these examples:
`This colors text the red index (r), the blue index (b) and the green index(g) and numeric
`Name of the color you give it so!
ink rgb(red,green,blue),colornum
set cursor x,y
Print string
text x,y,string
set text size textsize
set text font textfont (string)
If then statements are conditions, if endif is used when a condition is longer.
Give yourself a pat on the back you made your first game or at least your first pong game. Take
awhile play it with friends, and then get ready for a pop quiz.
***Quiz Time***
The Print Command Is Used For Printing Text?
True or False
The Repeat Until Loop Is Used In Our Pong Clone?
True or False
This is not an example of a real variable:
True or False
a# = 12.9818
Which is a string variable?:
1) a$ = "AAAA"
2) a# = 12444.11
3) a = 123
You can use the str$ command for converting a string to an integer?:
True or False
You can download the media, no source, or exe
Formerly Ogre Software
My Current Project: Mystic I: Quest of A Lifetime