Author Topic: Blitz Basic - 1st Attempt[BB2D]  (Read 12946 times)

0 Members and 1 Guest are viewing this topic.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Blitz Basic - 1st Attempt
« Reply #20 on: October 30, 2006 »
Also I wouldnt have the fonts loaded each time in the main loop.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

lilw4t3rdr0p

  • Guest
Re: Blitz Basic - 1st Attempt
« Reply #21 on: October 30, 2006 »
So you mean to put them before the while not keydown?

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Blitz Basic - 1st Attempt
« Reply #22 on: October 31, 2006 »
Yes mate. Otherwize they are always being loaded during the loop.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

lilw4t3rdr0p

  • Guest
Re: Blitz Basic - 1st Attempt
« Reply #23 on: October 31, 2006 »
Okay, Thanks a lot!

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17427
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: Blitz Basic - 1st Attempt
« Reply #24 on: October 31, 2006 »
Why didn't I see that? Doh!
Shockwave ^ Codigos
Challenge Trophies Won:

lilw4t3rdr0p

  • Guest
Re: Blitz Basic - 1st Attempt
« Reply #25 on: October 31, 2006 »
I think you were preoccupied! :)

Thanks for all your help. I will work on it some more today!

lilw4t3rdr0p

  • Guest
Re: Blitz Basic - 1st Attempt
« Reply #26 on: October 31, 2006 »
Here is the code after some changes and the tutorial.

I tried to change the speed on the Shapes and the random words, but could not get it to work.

Maybe I have not covered that yet.

Any suggestions or feedback would be great. Thanks.

Code: [Select]
; First Attempt
; By Lilw4t3rdr0p


; Open Screen
; X size, Y size, Bit depth, mode

Graphics 640,480,32,2

; Setbuffer

SetBuffer BackBuffer()

; Load fonts ("font", size, bold, italics, underline)

LF1 = LoadFont ("Batang", 20, True, False, False)
LF2 = LoadFont ("Chaucer", 24, False, False, True)
LF3 = LoadFont ("Cotillion", 22, True, False, True)

; Load varible

XPOS = 0

; Load Speed

Speed = 3

; Wait for Keypress

While Not KeyDown(1)

; Set font

SetFont LF1

; Set color

Color 222, 0, 0

; Command

Text XPOS, 242, "I love You!"

; Set varible

XPOS=XPOS+SPEED

; Set reverse

If XPOS> 640 Then SPEED = -2
If XPOS< 0 Then SPEED = 2

; Set font

SetFont LF2

; Set color

Color 0, 200, 15

; Command

Text 64, 194, "You Make My Dreams Come True."

; Set font

SetFont LF3

; Set color

Color 75, 75, 230

; Command

Text 262, 282, "Thank You!"

; Set color

Color 178, 178, 10

; Set command (text) (movement)

Text Rnd (180), 100, "DBF/GVY!"

; Set color

Color 178, 178, 10

; Command (text) (movement)

Text Rnd (460), 362, "WHOO!"

; Set color

Color 200, 200, 200

; Command (shape) (movement)

Rect Rnd (95), 42, 20, 20

; Set color

Color 225, 25, 255

; Command (shape) (movement)

Oval Rnd (237), 420, 20, 20

; Set color

Color 215, 50, 50

; Command (shape) (movement)

Oval Rnd (95), 42, 20, 20

; Set color

Color 25, 255, 255

; Command (shape) (movement)

Rect Rnd (237), 420, 20, 20

If XPOS> 640 Then SPEED = -2
If XPOS< 0 Then SPEED = 2


; Set to flip from logical to physical

Flip

; Set to slow (refresh)

VWait

; Close loop

Cls

; Start loop over (go back to the top)

Wend

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Blitz Basic - 1st Attempt
« Reply #27 on: October 31, 2006 »
First thing I spotted is that you are changing PosX twice in the loop.
Are you trying to get the shapes to move differently from the text? If so you will need another variable, perhaps something like PosX2

One other tip, its great you are commenting your code, to further help out you can press Tab to format parts of the program better.

Code: [Select]
; First Attempt
; By Lilw4t3rdr0p

;
; Open Screen:- Screen Width, Screen Height, Colour Bit depth, mode.
;
Graphics 640,480,32,2
SetBuffer BackBuffer()

;
; Load fonts ("font", size, bold, italics, underline)
;
LF1 = LoadFont ("Batang", 20, True, False, False)
LF2 = LoadFont ("Chaucer", 24, False, False, True)
LF3 = LoadFont ("Cotillion", 22, True, False, True)

;
; Setup variables.
;
XPOS = 0
Speed = 3; Load Speed


; Wait for Keypress

While Not KeyDown(1)


SetFont LF1 ; Set to use LF1 font
Color 222, 0, 0 ; Set color
Text XPOS, 242, "I love You!" ; Print x,y,text

;
; Increment speed.
;
XPOS=XPOS+SPEED

;
; Check Direction.
;
If XPOS> 640 Then SPEED = -2
If XPOS< 0 Then SPEED =  2


SetFont LF2 ; Set font
Color 0, 200, 15 ; Set color
Text 64, 194, "You Make My Dreams Come True." ; Print Text

SetFont LF3 ; Set font
Color 75, 75, 230 ; Set color
Text 262, 282, "Thank You!" ; Print Text

Color 178, 178, 10 ; Set color
Text Rnd (180), 100, "DBF/GVY!"

Color 178, 178, 10 ; Set color
Text Rnd (460), 362, "WHOO!" ; Print Text at Random X Position.

Color 200, 200, 200 ; Set color
Rect Rnd (95), 42, 20, 20 ; Command (shape) (movement)


Color 225, 25, 255 ; Set color
Oval Rnd (237), 420, 20, 20 ; Command (shape) (movement)

Color 215, 50, 50 ; Set color
Oval Rnd (95), 42, 20, 20 ; Command (shape) (movement)


Color 25, 255, 255 ; Set color
Rect Rnd (237), 420, 20, 20 ; Command (shape) (movement)


;If XPOS> 640 Then SPEED = -2
;'If XPOS< 0 Then SPEED = 2

Flip
VWait
Cls

Wend
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

lilw4t3rdr0p

  • Guest
Re: Blitz Basic - 1st Attempt
« Reply #28 on: October 31, 2006 »
So can I set more then one speed.

Like a different speed for each shape and text?

Set them like this:
Speed1 = 2
Speed2 = 4
Speed3 = 6
etc?

Command:
XPOS=XPOS1 ?

And (I may not be here yet) but how do I make them move vertically?

Thanks for the above comments. Very helpful.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17427
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: Blitz Basic - 1st Attempt
« Reply #29 on: October 31, 2006 »
Y_pos variables ? :)

remember;

Text X , Y , "TEXT"

:)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Blitz Basic - 1st Attempt
« Reply #30 on: October 31, 2006 »
For different speeds depending on the variable name it'll be something like this mate.
And did you know that the types of variables you are using are often called Local.

XPos1=XPos1+SpeedX1
XPos2=XPos2+SpeedX2
..etc
YPos1=YPos1+SpeedY1
YPos2=YPos2+SpeedY2

Btw, as a general rule that I use, I try not to use all capitals for Variable names, unless they are declared as Const ( constant: variables that stay the same through out )

For example, seeing as the Resolution of the Screen is going to be the same throughout and wont ever change.
You can have something like this.

Code: [Select]
Const ScreenHeight=640
Const ScreenWidth=480

Graphics ScreenHeight, ScreenWidth,32,2
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

lilw4t3rdr0p

  • Guest
Re: Blitz Basic - 1st Attempt
« Reply #31 on: October 31, 2006 »
Hmmm. Interesting. Makes sense. Okay. Thanks.

lilw4t3rdr0p

  • Guest
Re: Blitz Basic - 1st Attempt
« Reply #32 on: November 03, 2006 »
Do I use the same idea to change the speed of the shapes?

The new additions to the code and I are not friends. I will try some more and if I can't get it myself, then I will post for suggestions.

:)

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: Blitz Basic - 1st Attempt
« Reply #33 on: November 05, 2006 »
Definitely a karma moment posting your first program!
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Blitz Basic - 1st Attempt
« Reply #34 on: November 05, 2006 »
@LWD: Yes dude if you like you can use the very same mate.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won: