For loops?

Blitz3D Forums/Blitz3D Beginners Area/For loops?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Yeah i hate when that happens to games, my cousins
computer does that all the time when it run 2d games.

Btw her is my "Math Drill" feel
free to change the source.

All@ bet you cant be better
than "Not Good.." hehe


; Title

AppTitle "Math Drill"


; Graphics Mode

Graphics 640, 480, 16, 2

SetBuffer BackBuffer()


; Super Randomize

SeedRnd MilliSecs()


; Small Number Dim

Dim number_s(8)

For x = 0 To 8

number_s(x) = Rnd( 1, 9 )

Next


; Big Number Dim

Dim number_b(8)

For x = 0 To 8

number_b(x) = Rnd( 100, 999 )

Next


; Anserw Type

Type ans

Field a.ans, ans_a
Field ans_x, ans_y, ans_c

End Type



; Start

.start


; Set Right Anserws To Zero

Global righta = 0

Global marker_x = 0, marker_y = 0

Global finished = False, count_answers = False

Global time = 600, time_r = MilliSecs()


; Delete All Previous Anservs

For a.ans = Each ans

Delete a

Next


; Create Anserw Types

For x = 0 To 8

For y = 0 To 8

a.ans = New ans
a\ans_x = x * 33 + 204
a\ans_y = y * 17 + 174
a\ans_a$ = 0
a\ans_c = 0

Next

Next


; Program Lol

While KeyHit(1) = False


; Time

If MilliSecs() > time_r + 1000 Then

If time > 0 Then time = time - 1

time_r = MilliSecs()

EndIf


; Time Up !

If time < 1 Then

finished = True

EndIf



; Get ASCII

key = GetKey()


; Number True

If key > 47 And key < 58 Then

For a.ans = Each ans

If ( a\ans_x - 204 ) / 33 = marker_x And ( a\ans_y - 174 ) / 17 = marker_y Then

If Len( a\ans_a$ ) < 4 Then a\ans_a$ = a\ans_a + Chr$( key )

EndIf

Next

EndIf


; Bakspace True

If key = 8 Then

For a.ans = Each ans

If ( a\ans_x - 204 ) / 33 = marker_x And ( a\ans_y - 174 ) / 17 = marker_y Then

a\ans_a$ = Left$( a\ans_a$, Len( a\ans_a$ ) - 1 )

EndIf

Next

EndIf


; Enter True

If KeyHit(28) Then

For a.ans = Each ans

If ( a\ans_x - 204 ) / 33 = marker_x And ( a\ans_y - 174 ) / 17 = marker_y Then

If number_b( marker_y ) / number_s( marker_x ) = a\ans_a$ Then

a\ans_c = 1

marker_y = marker_y + 1

If marker_y > 8 Then marker_y = 0 : marker_x = marker_x + 1

If marker_x = 9 Then finished = True

Goto q

Else

a\ans_c = 2

marker_y = marker_y + 1

If marker_y > 8 Then marker_y = 0 : marker_x = marker_x + 1

If marker_x = 9 Then finished = True

Goto q

EndIf

EndIf

Next

EndIf

.q



; Clear Screen

Cls


; Draw Board

Color 0, 255, 0

Text 320, 64, "* Math Drill *", 1

Color 255, 0, 0

Rect 154, 154, 33 * 10 + 1, 17 * 10 + 1, 1

Gosub drawboard


; Draw Small Numbers

For x = 0 To 8

Color 0, 0, 0

Text x * 33 + 204, 157, number_s(x), 1

Next


; Draw Big Numbers

For y = 0 To 8

Color 0, 0, 0

Text 171, y * 17 + 174, number_b(y), 1

Next

; Cheat Switch

If key = 99 Then If cheat = True Then cheat = False : key = 0

If key = 99 Then If cheat = False Then cheat = True : key = 0


; Cheat By Pressing [ C ]

If cheat = True Then

For a.ans = Each ans

If ( a\ans_x - 204 ) / 33 = marker_x And ( a\ans_y - 174 ) / 17 = marker_y Then

Color 0, 255, 0

Text 320, 90, number_b( marker_y ) / number_s( marker_x ), 1

EndIf

Next

EndIf


; Draw Marker

Color 0, 0, 255

If marker_x < 9 Then Rect marker_x * 33 + 187, marker_y * 17 + 171, 34, 18, 0


; Draw Anserw Types

For a.ans = Each ans

If a\ans_c = 0 Then Color 0, 0, 255

If a\ans_c = 1 Then Color 0, 255, 0

If a\ans_c = 2 Then Color 255, 0, 0

Text a\ans_x, a\ans_y, a\ans_a, 1

Next


; Draw Time Left

Color 255, 0, 0

Text 320, 380, "Time Left " + time + " ( Sec ) ", 1


; Display Results

If finished = True Then

If count_answers = False

For a.ans = Each ans

If a\ans_c = 1 Then righta = righta + 1

Next

EndIf

count_answers = True

Text 320, 400, righta + " Right Anserw Of 81", 1

If righta < 21 Then Text 320, 420, " Very Bad ! ", 1

If righta > 20 And righta < 41 Then Text 320, 420, " Not Good.. ", 1

If righta > 40 And righta < 61 Then Text 320, 420, " Better Practice More ", 1

If righta > 60 And righta < 81 Then Text 320, 420, " Greate Work ", 1

If righta = 81 Then Text 320, 420, " Master Mind ! ", 1

Text 320, 440, " Try Again ? Y/N ", 1

If key = 121 Then Goto start

If key = 110 Then Goto endp

EndIf


; Of Course I Gotta Sign This =)

Text 320, 460, "By Cermit =)", 1


; Flip Buffer

Flip


; Program End

Wend

.endp

End


; Draw Board

.drawboard

For x = 0 To 9

For y = 0 To 9

Color 255, 128, 0

Rect x * 33 + 155, y * 17 + 155, 32, 16, 1

Next

Next

Return



You can see the right answer by pressing "c"
Cheating is not good i know but i just wanted
to see that my math did work =)

I hate when they do these 10 minutes tests
in school so i didnt try it serious myself =)
We'll say i got "Master Mind !" ( i didnt cheat
i promise *ironic* )