Main Menu

Need alot of help

Started by Darfox8, August 22, 2005, 11:00:49 PM

Previous topic - Next topic

Darfox8

Hi my first post. I really want to start making games now. I was thinking of making a 2D shooter like Megaman or Contra. Is this program right for that. And either way how can I get a very easy to understand guideline to making games.

Thanks

kevin

#1
Darfox8,

  Firstly, Welcome..   Games like MegaMan, could certainly be developed in PlayBASIC, with an experienced programmer and artist!.

  Ok, so If you've never done any programming before, then it's prolly best to set your sights on something really simple (i know that's probably not what your wanted to hear!).. Then once you've gained your sea legs, then jump into learning how to develop more complex and exciting games.

  First up,  You'll need top learn about Variables/Arrays,  so make sure you read through those tutorials in the help-> under about section.  Be sure to examine the demo / example codes supplied.  Try messing with the small ones.  For any highlighted command you can't understand, move the mouse pointer over this command and the press the F1 key.  This will take you to the commands help page.

  Anyway, While it's not very exciting developing a "Pong" game say, it'd be great way to gain some experience quickly.  As It requires you deal with the basic fundamentals found in virtually every video game.   (Player control, Collisions and AI)

  Here's a bit of start for you,   (cut and paste this code into the editor, hit F5 to execute it)


PlayBASIC Code: [Select]
; Create a variable to hold our Balls X position value
BallX =100

; Create a variable to hold our Balls Y position value
BallY = 200

; Create a variable to hold our Balls Size
BallSize=30


; Start a Do/loop (this keeps the program runngin)
Do
; Clear the screen to black
Cls rgb(0,0,0)


; Draw the Ball (a circle will represent the ball in this demo)
Circle BallX,BallY,BallSize,1



; Display the Screen
Sync

; Loop back to the DO statement and continue this loop
loop






 
Some challenges for you.

 Change this code,

 * So the ball starts at position 400X,300Y
 * Set the balls size to 20
 * So the ball is hollow (hint - see the circle commands help)
 * Change the colour of the screen from Black (Rgb (0,0,0) to  say BLUE  
 * Make the ball move.   (Adjust the ball variables (their values) to created movement)

 I'll post some answers later on today/tomorrow .. Good luck !


Darfox8

#2
Thanks alot. Your a god send. I don't care about baby steps as long as I'm learning so don't worry about boring me. As for the challenges I only got these. I'm missing the ones that are an actaul challenge.

PlayBASIC Code: [Select]
; Create a variable to hold our Balls X position value
BallX =400

; Create a variable to hold our Balls Y position value
BallY = 300

; Create a variable to hold our Balls Size
BallSize=20


; Start a Do/loop (this keeps the program runngin)
Do
; Clear the screen to black
Cls RGB(0,0,255)


; Draw the Ball (a circle will represent the ball in this demo)
Circle BallX,BallY,BallSize,1



; Display the Screen
Sync

; Loop back to the DO statement and continue this loop
Loop


I tried to move the ball, as you said, by adding a "=" and a number but it would only appear at the corner of the screen.

kevin

#3
Here's the challenge answers for anybody whom wanted them.


===================================================
* So the ball starts at position 400X,300Y
===================================================


PlayBASIC Code: [Select]
; Create a variable to hold our Balls X position value
; <<>>>
; Set the BallX variable to a value of 400
; <<>>>
BallX =400

; Create a variable to hold our Balls Y position value
; <<>>>
; Set the BallY variable to a value of 300
; <<>>>
BallY = 300


; Create a variable to hold our Balls Size
BallSize=30


; Start a Do/loop (this keeps the program running)
Do
; Clear the screen to black
Cls rgb(0,0,0)


; Draw the Ball (a circle will represent the ball in this demo)
Circle BallX,BallY,BallSize,1

; Display the Screen
Sync

; Loop back to the DO statement and continue this loop
loop




===================================================
* Set the balls size to 20
===================================================

PlayBASIC Code: [Select]
; Create a variable to hold our Balls X position value
BallX =400

; Create a variable to hold our Balls Y position value
BallY = 300

; Create a variable to hold our Balls Size (set new size to 20)
BallSize=20

; Start a Do/loop (this keeps the program running)
Do
; Clear the screen to black
Cls rgb(0,0,0)


; Draw the Ball (a circle will represent the ball in this demo)
Circle BallX,BallY,BallSize,1

; Display the Screen
Sync

; Loop back to the DO statement and continue this loop
loop




===================================================
* So the ball is hollow (hint - see the circle commands help)
===================================================

PlayBASIC Code: [Select]
; Create a variable to hold our Balls X position value
; <<>>>
; Set the BallX vairable to a value of 400
; <<>>>
BallX =400

; Create a variable to hold our Balls Y position value
; <<>>>
; Set the BallY variable to a value of 300
; <<>>>
BallY = 300


; Create a variable to hold our Balls Size (set new size to 20)
; <<>>>
; Set the BallSize Variable to a value of 20
; <<>>>
BallSize=20


; Start a Do/loop (this keeps the program running)
Do
; Clear the screen to black
Cls rgb(0,0,0)


; Draw the Ball (a circle will represent the ball in this demo)
; <<>>>
; By changing the Last parameter of the circle command
; to zero, we can make the circle hollow
; <<>>>
Circle BallX,BallY,BallSize,0


; Display the Screen
Sync

; Loop back to the DO statement and continue this loop
loop





==================================================
* Change the colour of the screen from Black (Rgb (0,0,0) to say BLUE
==================================================

PlayBASIC Code: [Select]
; Create a variable to hold our Balls X position value
; <<>>>
; Set the BallX variable to a value of 400
; <<>>>
BallX =400

; Create a variable to hold our Balls Y position value
; <<>>>
; Set the BallY variable to a value of 300
; <<>>>
BallY = 300


; Create a variable to hold our Balls Size (set new size to 20)
; <<>>>
; Set the BallSize Variable to a value of 20
; <<>>>
BallSize=20


; Start a Do/loop (this keeps the program running)
Do
; Clear the screen to black
; <<>>>
; By using the RGB command i've changed the screen
; colour to BLUE RGB(0,0,255)

; RGB stands for RED, GREEN , BLUE. The RGB command
; accepts levels of Red/Green & Blue, between 0 and 255.
; So you create colours by mixing the levels of Red, Green
; Blue
; <<>>>

Cls rgb(0,0,255)


; Draw the Ball (a circle will represent the ball in this demo)
; <<>>>
; By changing the Last parameter of the circle command
; to zero, we can make the circle hollow
; <<>>>

Circle BallX,BallY,BallSize,0


; Display the Screen
Sync

; Loop back to the DO statement and continue this loop
loop





======================================================
* Make the ball move. (Adjust the ball variables (their values) to created movement)
======================================================

To make the move, we need to modify the values in the variables that store the balls position.

In this example the variables BallX & BallY are used as the ball posiiton on the
screen. Which are Initially set to 400x and 300y.  

If we wish to move the Ball only along the X axis, we need to either Add or subtract from this variable.    To do this we use a simple formula.   This formula takes the form of  Result = Calculation.

Since we wish to change the BallX variables value.  Our result will need to be stored in our BallX variable.   So for starters we'd get this.

BallX = Calculation.

Now lets say we want to move the Ball across the screen to the right.   And since the coordinates of the screen (along the X axis) run left to Right (from zero to the Screen s width)  i.e  0 to 800, 0 to 1024..  This means that in order to move RIGHT we have to ADD a value to the balls current position.  The bigger the value the faster the ball will move !

So lets say we want to add 2 to the current balls X position.  To do this we need to create a calculation that takes the balls current X position and then adds two to it.. So the calculation side of our formula would look like this.

  BallX+2


 And when we finally put the two sides together, we'd get something like this.

BallX = BallX + 2


if you think about it, that line of code is basically saying the NEW BALL X position = Current Ball X position + 2

Note : The Calculation side after the equals sign is resolved first, then the answer is written to the Left hand side  


Example #1.

BallX = 100

BallX = BallX+5

After running this code once, The BALLX variable would equal 105 (100+5)
       

Example #2.

BallX = 300

BallSpeed = 4

BallX = BallX+BallSpeed


After running this code once, The BALLX variable would equal 304 (300+4)


For more information on variables, please read then Variable Tutorial in the PLayBASIC Doc's


PlayBASIC Code: [Select]
; Create a variable to hold our Balls X position value
; <<>>>
; Set the BallX variable to a value of 400
; <<>>>
BallX =400

; Create a variable to hold our Balls Y position value
; <<>>>
; Set the BallY variable to a value of 300
; <<>>>
BallY = 300


; Create a variable to hold our Balls Size (set new size to 20)
; <<>>>
; Set the BallSize Variable to a value of 20
; <<>>>
BallSize=20


; Start a Do/loop (this keeps the program running)
Do
; Clear the screen to black
; <<>>>
; By using the RGB command and we've changed the screen
; colour to BLUE (0,0,255)
; RGB stands for RED, GREEN , BLUE. The RGB commands
; accepts levels of Red/GreenBlue, between 0 and 255.
; you create other colours by miving the level of Red,Green,Blue
; <<>>>
Cls rgb(0,0,255)


; Draw the Ball (a circle will represent the ball in this demo)
; <<>>>
; By changing the Last parameter of the circle command
; to zero, we can make the circle hollow
; <<>>>
Circle BallX,BallY,BallSize,0

; MOVE THE BALL along the X AXIS
BallX = BallX + 1

; MOVE THE BALL along the Y AXIS
BallY = BallY + 1

; Display the Screen
Sync

; Loop back to the DO statement and continue this loop
loop




Now,  Cut and paste the various source code fragments into PlayBASIC and see what happens.    Not sure how to do that ? - Well, the Tutorial bellow covers pretty much everything a new programmer needs to know about the classic IDE.


  PlayBasic IDE - Getting Started Tutorial: