Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 can someone fix my problem
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bball_mvp88




PostPosted: Tue May 25, 2004 6:51 pm   Post subject: can someone fix my problem

can some tell me why the program will not sum up the cards??? please

drawfillbox (0,0,640,400,7)
colourback(7)

colour (0)
var name:string
locate (12,35)
put "Enter Your Name:"
locate (13,35)
get name

cls
drawfillbox (10,10,630,400,7)
colourback(7)

colour (0)
var money:real
locate (11,26)
put "You have 20 dollars to bet"
locate (12,19)
put "How much do you what to bet on this game?"
locate (13,35)
get money
cls
loop
if money >= 20 then
locate (11,21)
put "You do not have enough money to bet!!!"
locate (12,19)
put "How much do you what to bet on this game?"
locate (13,35)
get money
cls
end if
exit when money <=20
end loop

drawfillbox (10,10,630,400,7)

var font1:int
font1 := Font.New ("Arial Black:15")
Font.Draw ("Dealer", 293, 340, font1, 0)
Font.Free (font1)

font1 := Font.New ("Arial Black:15")
Font.Draw (name, 95, 300, font1, 0)
Font.Free (font1)


font1 := Font.New ("Arial Black:15")
Font.Draw ("Computer", 465, 300, font1, 0)
Font.Free (font1)

var pic3 : int := Pic.FileNew ("cardback.jpg")
if pic3 = 0 then
put "Unable to load JPEG: ", Error.LastMsg
return
end if
Pic.Draw (pic3, 260, 140, picCopy)

drawbox (380,80,280,120,0)

font1 := Font.New ("Arial Black:13")
Font.Draw ("Start", 308, 95, font1, 0)
Font.Free (font1)

var x4,y4,bnum4,bud4:int

loop
buttonwait ("down", x4, y4, bnum4, bud4)

if x4 >= 280 and x4 <= 380 and y4 >= 80 and y4 <= 120 then

drawfillbox (10,10,630,400,7)






font1 := Font.New ("Arial Black:10")
Font.Draw ("You have dollar(s). You betted for this game of Blackjack.", 5, 375, font1, 0)
Font.Free (font1)


font1 := Font.New ("Arial Black:15")
Font.Draw ("Dealer", 293, 340, font1, 0)
Font.Free (font1)

font1 := Font.New ("Arial Black:15")
Font.Draw (name, 95, 300, font1, 0)
Font.Free (font1)


font1 := Font.New ("Arial Black:15")
Font.Draw ("Computer", 465, 300, font1, 0)
Font.Free (font1)


if pic3 = 0 then
put "Unable to load JPEG: ", Error.LastMsg
return
end if
Pic.Draw (pic3, 260, 140, picCopy)

drawbox (380,80,280,120,0)
drawbox (380,30,280,70,0)
font1 := Font.New ("Arial Black:13")
Font.Draw ("Hit", 315, 95, font1, 0)
Font.Free (font1)
font1 := Font.New ("Arial Black:13")
Font.Draw ("Stay", 308, 45, font1, 0)
Font.Free (font1)


var p1 : int := Pic.FileNew ("acehearts.jpg")
var p2 : int := Pic.FileNew ("aceclubs.jpg")
var p3 : int := Pic.FileNew ("acediamonds.jpg")
var p4 : int := Pic.FileNew ("acespades.jpg")
var p5 : int := Pic.FileNew ("twohearts.jpg")
var p6 : int := Pic.FileNew ("twoclubs.jpg")
var p7 : int := Pic.FileNew ("twospades.jpg")
var p8 : int := Pic.FileNew ("twodiamonds.jpg")
var p9 : int := Pic.FileNew ("threehearts.jpg")
var p10 : int := Pic.FileNew ("threeclubs.jpg")
var p11 : int := Pic.FileNew ("threespades.jpg")
var p12 : int := Pic.FileNew ("threediamonds.jpg")
var p13 : int := Pic.FileNew ("fourhearts.jpg")
var p14 : int := Pic.FileNew ("fourclubs.jpg")
var p15 : int := Pic.FileNew ("fourspades.jpg")
var p16 : int := Pic.FileNew ("fourdiamonds.jpg")
var p17 : int := Pic.FileNew ("fivehearts.jpg")
var p18 : int := Pic.FileNew ("fiveclubs.jpg")
var p19 : int := Pic.FileNew ("fivespades.jpg")
var p20 : int := Pic.FileNew ("fivediamonds.jpg")
var p21 : int := Pic.FileNew ("sixhearts.jpg")
var p22 : int := Pic.FileNew ("sixclubs.jpg")
var p23 : int := Pic.FileNew ("sixspades.jpg")
var p24 : int := Pic.FileNew ("sixdiamonds.jpg")
var p25 : int := Pic.FileNew ("sevenhearts.jpg")
var p26 : int := Pic.FileNew ("sevenclubs.jpg")
var p27 : int := Pic.FileNew ("sevendiamonds.jpg")
var p28 : int := Pic.FileNew ("sevenspades.jpg")
var p29 : int := Pic.FileNew ("eighthearts.jpg")
var p30 : int := Pic.FileNew ("eightclubs.jpg")
var p31 : int := Pic.FileNew ("eightspades.jpg")
var p32 : int := Pic.FileNew ("eightdiamonds.jpg")
var p33 : int := Pic.FileNew ("ninehearts.jpg")
var p34 : int := Pic.FileNew ("nineclubs.jpg")
var p35 : int := Pic.FileNew ("ninespades.jpg")
var p36 : int := Pic.FileNew ("ninediamonds.jpg")
var p37 : int := Pic.FileNew ("tenhearts.jpg")
var p38 : int := Pic.FileNew ("tenclubs.jpg")
var p39 : int := Pic.FileNew ("tenspades.jpg")
var p40 : int := Pic.FileNew ("tendiamonds.jpg")
var p41 : int := Pic.FileNew ("jackhearts.jpg")
var p42 : int := Pic.FileNew ("jackclubs.jpg")
var p43 : int := Pic.FileNew ("jackspades.jpg")
var p44 : int := Pic.FileNew ("jackdiamonds.jpg")
var p45 : int := Pic.FileNew ("queenhearts.jpg")
var p46 : int := Pic.FileNew ("queenclubs.jpg")
var p47 : int := Pic.FileNew ("queenspades.jpg")
var p48 : int := Pic.FileNew ("queendiamonds.jpg")
var p49 : int := Pic.FileNew ("kinghearts.jpg")
var p50 : int := Pic.FileNew ("kingclubs.jpg")
var p51 : int := Pic.FileNew ("kingspades.jpg")
var p52 : int := Pic.FileNew ("kingdiamonds.jpg")

randomize
var y:int:=0
randint (y,p1,p52)
var x:int:=0
randint (x,p1,p52)

Pic.Draw (x, 40, 90, picCopy)
Pic.Draw (y, 60, 70, picCopy)
var sum:int:=0
var x5,y5,bnum5,bud5:int
var e:int:=0
loop
buttonwait ("down", x5, y5, bnum5, bud5)

if x5 >= 280 and x5 <= 380 and y5 >= 80 and y5 <= 120 then

var p:int:=0
randint (p,p1,p52)

Pic.Draw (p, 80, 50, picCopy)
p:=e
end if

var m:int:=0
var x6,y6,bnum6,bud6:int
loop
buttonwait ("down", x6, y6, bnum6, bud6)

if x6 >= 280 and x6 <= 380 and y6 >= 80 and y6 <= 120 then

var k:int:=0
randint (k,p1,p52)
Pic.Draw (k, 100, 30, picCopy)
k:=m
end if


var x7,y7,bnum7,bud7:int
loop
buttonwait ("down", x7, y7, bnum7, bud7)

if x7 >= 280 and x7 <= 380 and y7 >= 30 and y7 <= 70 then

p1 :=1
p2 :=1
p3 :=1
p4 :=1
p5 :=2
p6 :=2
p7 :=2
p8 :=2
p9 :=3
p10 :=3
p11 :=3
p12 :=3
p13 :=4
p14 :=4
p15 :=4
p16 :=4
p17 :=5
p18 :=5
p19 :=5
p20 :=5
p21 :=6
p22 :=6
p23 :=6
p24 :=6
p25 :=7
p26 :=7
p27 :=7
p28 :=7
p29 :=8
p30 :=8
p31 :=8
p32 :=8
p33 :=9
p34 :=9
p35 :=9
p36 :=9
p37 :=10
p38 :=10
p39 :=10
p40 :=10
p41 :=10
p42 :=10
p43 :=10
p44 :=10
p45 :=10
p46 :=10
p47 :=10
p48 :=10
p49 :=10
p50 :=10
p51 :=10
p52 :=10

sum:=sum+y
sum:=sum+x
sum:=sum+m
sum:=sum+e
put sum

end if

end loop
end loop
end loop
end if

end loop
Sponsor
Sponsor
Sponsor
sponsor
guruguru




PostPosted: Tue May 25, 2004 7:06 pm   Post subject: (No subject)

Wow... no offense... but that is possibly the worst code I have ever seen.

Anyways... for your problem: You are redeclaring variables everytime through the loops. Simple declare the vairable at the beggining of the program, and then assign values to them in the loops.
vagyb




PostPosted: Tue May 25, 2004 7:30 pm   Post subject: (No subject)

YES!! hehe my codes are at least better than someones hehe Very Happy

btw lol i mean this with no offence or anything just joking around cuz my codes suck pretty bad too
omni




PostPosted: Tue May 25, 2004 7:30 pm   Post subject: (No subject)

you could optimize all those pictures into a 2d array. Wow that is sooo much typing..
Pickles




PostPosted: Tue May 25, 2004 7:53 pm   Post subject: ..

Also be careful with the locate as maxrows and maxcols arent the same on every computer, and it can make your program look pretty cheap.

locatexy and then referring to maxx,maxy ie
locatexy(maxx div 2, maxy div 2) to place it in the middle of the screen
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: