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

Username:   Password: 
 RegisterRegister   
 My final project but having problem with it...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jhdho0204




PostPosted: Sun Jan 23, 2011 12:19 pm   Post subject: My final project but having problem with it...

%Welcome
setscreen ("offscreenonly")
var row, column : int
var o : int := 0
var p : int := 300
var title : int
var pic2 : int
var x, y, bnum, bdummy : int
var font1, font2, font3, font4, font5 : int
var pic : int
var current : int := 1
var purchase, purchase1, purchase2, purchase3, purchase4 : real
%category

var pro1 : int := Pic.FileNew ("ipodtouch.jpg")
var pro2 : int := Pic.FileNew ("ipod_edited-1.jpg")
var pro3 : int := Pic.FileNew ("desktop3.jpg")
var pro4 : int := Pic.FileNew ("macbook.jpg")
var pro5 : int := Pic.FileNew ("iphone.jpg")


font1 := Font.New ("TypeMaker:30:bold")
font2 := Font.New ("TypeMaker:20:bold")
font3 := Font.New ("Times New Roman:12:bold")
font4 := Font.New ("Times New Roman:16:bold")
font5 := Font.New ("TypeWriter:16:bold")

for i : 1 .. maxx by 50
%moon
drawfilloval (o, p, 50, 50, yellow)
drawfillbox (o - 30, p, o - 10, p + 20, 7)
drawfillbox (o + 20, p, o + 40, p + 20, 7)
Draw.ThickLine (o - 20, p + 10, o + 20, p + 10, 5, 7)
drawfillarc (o, p - 20, 30, 20, 180, 360, red)
o := 10 + i
View.Update
delay (1)
cls
%stars
delay (1)
randint (row, 1, maxx)
randint (column, 1, maxy)
color (yellow)
drawfillstar (row, column, row + 20, column + 20, yellow)
delay (50)
randint (row, 1, maxx)
randint (column, 1, maxy)
color (yellow)
drawfillstar (row, column, row + 20, column + 20, yellow)
delay (50)
randint (row, 1, maxx)
randint (column, 1, maxy)
color (yellow)
drawfillstar (row, column, row + 20, column + 20, yellow)
delay (50)
randint (row, 1, maxx)
randint (column, 1, maxy)
color (yellow)
drawfillstar (row, column, row + 20, column + 20, yellow)

Font.Draw ("JJ.Apple", 250, 350, font1, red)
Font.Draw ("Press anywhere", 230, 100, font2, green)
Font.Draw ("to start", 270, 75, font2, green)
end for

buttonwait ("down", x, y, bnum, bdummy)
if x >= 0 and y >= 0 and x <= maxx and y <= maxy then
current := 1
cls
end if
if (current = 1) then
%category
drawfillbox (0, 0, 160, 70, red)
Font.Draw ("Exit", 20, 20, font5, white)
Font.Draw ("Category", 260, 380, font5, black)
Font.Draw ("Ipod Touch", 200, 230, font5, black)
Font.Draw ("Ipod Nano", 460, 215, font5, black)
Font.Draw ("Mac Computer", 450, 10, font5, black)
Font.Draw ("Macbook Air", 200, 10, font5, black)
Font.Draw ("Iphone", 0, 80, font5, black)

Pic.Draw (pro1, 200, 250, picCopy)
View.Update

Pic.Draw (pro2, 460, 230, picCopy)
View.Update

Pic.Draw (pro3, 450, 30, picCopy)
View.Update

Pic.Draw (pro4, 180, 30, picCopy)
View.Update

Pic.Draw (pro5, 0, 100, picCopy)
View.Update


buttonwait ("down", x, y, bnum, bdummy)

if x >= 0 and y >= 0 and x <= 160 and y <= 70 then
current := 7
elsif x >= 0 and y >= 100 and x <= 168 and y <= 385 then
current := 2
elsif x >= 200 and y >= 250 and x <= 450 and y <= 360 then
current := 3
elsif x >= 180 and y >= 30 and x <= 440 and y <= 220 then
current := 4
elsif x >= 450 and y >= 30 and x <= 630 and y <= 210 then
current := 5
elsif x >= 460 and y >= 230 and x <= 630 and y <= 380 then
current := 6
end if
cls

%iphone
elsif (current = 2) then

drawfillbox (20, 140, 120, 80, red)
drawfillbox (20, 60, 120, 0, red)

Font.Draw ("Iphone", 10, 145, font4, black)
Font.Draw ("Purchase", 28, 105, font4, white)
Font.Draw ("This is a 4th gen Iphone, with great application you're able to", 230, 380, font3, black)
Font.Draw ("use Facetime with the people you wishes to for free, and with", 230, 360, font3, black)
Font.Draw ("just a touch of the phone you'll be able to call someone", 230, 340, font3, black)
Font.Draw ("you wishes to call. Also it is available for game for people", 230, 320, font3, black)
Font.Draw ("who enjoys playing games. You'll also be able to access", 230, 300, font3, black)
Font.Draw ("Internet anywhere once you pay for the wifi. We only", 230, 280, font3, black)
Font.Draw ("offer 8gb :0. Thank you.", 230, 260, font3, black)
Font.Draw ("Go back", 28, 25, font4, white)
Font.Draw ("Price without contract: 789.99", 360, 30, font4, white)
Font.Draw ("Price with contract: 299.99", 360, 10, font4, black)


Pic.Draw (pro5, 0, 160, picCopy)
View.Update

buttonwait ("down", x, y, bnum, bdummy)
loop
if x >= 20 and y >= 140 and x <= 120 and y <= 200 then
Text.Locate (10, 25)
put "Type the number of items you want to purchase:"
Text.Locate (11, 25)
get purchase
elsif x >= 20 and y >= 60 and x <= 120 and y <= 120 then
end if
exit when x >= 20 and y >= 60 and x <= 120 and y <= 120
end loop
cls


Pic.Draw (pro5, 0, 240, picCopy)
View.Update

buttonwait ("down", x, y, bnum, bdummy)
loop
if x >= 20 and y >= 140 and x <= 120 and y <= 200 then
Text.Locate (10, 25)
put "Type the number of items you want to purchase:"
Text.Locate (11, 25)
get purchase
elsif x >= 20 and y >= 60 and x <= 120 and y <= 120 then
current := 1
end if
exit when x >= 20 and y >= 60 and x <= 120 and y <= 120
end loop
cls

elsif (current = 6) then

% Ipod Nano
drawfillbox (20, 140, 120, 200, red)
drawfillbox (20, 60, 120, 120, red)

Font.Draw ("Ipod nano", 10, 220, font4, black)
Font.Draw ("Purchase", 28, 165, font4, white)
Font.Draw ("This is the first Ipod Nano with touch screen. Also the size", 230, 380, font3, black)
Font.Draw ("of the this item is smaller then the ones that was in the past", 230, 360, font3, black)
Font.Draw ("also it has a great capacity so you'll be able to store a lot", 230, 340, font3, black)
Font.Draw ("of songs that you enjoy listemomg to.", 230, 320, font3, black)
Font.Draw (" We only offer 16gb :0. Thank you.", 230, 300, font3, black)
Font.Draw ("Go back", 28, 85, font4, white)
Font.Draw ("Price: 159.99", 360, 30, font4, black)


Pic.Draw (pro2, 0, 240, picCopy)
View.Update

buttonwait ("down", x, y, bnum, bdummy)
loop
if x >= 20 and y >= 140 and x <= 120 and y <= 200 then
Text.Locate (10, 25)
put "Type the number of items you want to purchase:"
Text.Locate (11, 25)
get purchase1
elsif x >= 20 and y >= 60 and x <= 120 and y <= 120 then
current := 1
end if
exit when x >= 20 and y >= 60 and x <= 120 and y <= 120
end loop
cls

%ipod touch
elsif (current = 3) then

drawfillbox (20, 180, 120, 230, red)
drawfillbox (20, 100, 120, 150, red)

Font.Draw ("Ipod touch", 10, 270, font4, black)
Font.Draw ("Purchase", 28, 200, font4, white)
Font.Draw ("This IPod Touch is the most recent one that that has been ", 250, 380, font3, black)
Font.Draw ("released through out the year. It also has a camera", 250, 360, font3, black)
Font.Draw ("differently from other Ipod Touches. It also has a", 250, 340, font3, black)
Font.Draw ("Facetime so you'll be able to speak with so you'll be", 250, 320, font3, black)
Font.Draw ("able to talk and see there face at the same time for free.", 250, 300, font3, black)
Font.Draw ("Sadly we only have 8gb.. sorry for the inconvinience. Sad", 250, 280, font3, black)
Font.Draw ("Go back", 28, 120, font4, white)

Pic.Draw (pro1, 0, 290, picCopy)
View.Update

buttonwait ("down", x, y, bnum, bdummy)
loop
if x >= 20 and y >= 180 and x <= 120 and y <= 230 then
Text.Color (white)
Text.Locate (10, 25)
put "Type the number of items you want to purchase:"
Text.Locate (11, 25)
get purchase2
elsif x >= 20 and y >= 100 and x <= 120 and y <= 150 then
current := 1
end if
exit when x >= 20 and y >= 100 and x <= 120 and y <= 150
end loop
cls

%Macbook Air

elsif (current = 4) then
drawfillbox (20, 180, 120, 230, red)
drawfillbox (20, 100, 120, 150, red)

Font.Draw ("Macbook Air", 10, 245, font4, black)
Font.Draw ("Purchase", 28, 200, font4, white)
Font.Draw ("This is the new generation of Macbook.", 270, 380, font3, black)
Font.Draw ("It has been released very recently with", 270, 360, font3, black)
Font.Draw ("better technology for the benefit for the", 270, 340, font3, black)
Font.Draw ("user. It has a better quality in order for", 270, 320, font3, black)
Font.Draw ("the user so it is more efficient and better", 270, 300, font3, black)
Font.Draw ("then the past ones.", 270, 280, font3, black)
Font.Draw ("Go back", 28, 120, font4, white)
Font.Draw ("Price: 1199.99", 500, 10, font4, black)

Pic.Draw (pro1, 0, 260, picCopy)
View.Update

buttonwait ("down", x, y, bnum, bdummy)
if x >= 20 and y >= 180 and x <= 120 and y <= 230 then
Text.Color (red)
Text.Locate (10, 25)
put "Type the number of items you want to purchase:"
Text.Locate (11, 25)
get purchase3
elsif x >= 20 and y >= 100 and x <= 120 and y <= 150 then
current := 1
end if

%Mac Computer
elsif (current = 5) then
drawfillbox (20, 110, 120, 170, red)
drawfillbox (20, 30, 120, 90, red)

Font.Draw ("Mac computer", 10, 210, font4, black)
Font.Draw ("Purchase", 28, 135, font4, white)
Font.Draw ("This is the mac computer that has been", 180, 380, font3, black)
Font.Draw ("released a long time ago. Most of our users", 180, 360, font3, black)
Font.Draw ("are a artisian or one's who makes video. It is very", 180, 340, font3, black)
Font.Draw ("useful for the people who are very interested with art", 180, 320, font3, black)
Font.Draw ("and with great graphic card it has a great quality.", 180, 300, font3, black)
Font.Draw ("Go back", 28, 55, font4, white)
Font.Draw ("Price: 1299.99", 500, 10, font4, black)

Pic.Draw (pro1, 0, 230, picCopy)
View.Update

buttonwait ("down", x, y, bnum, bdummy)
if x >= 20 and y >= 110 and x <= 120 and y <= 170 then
Text.Color (red)
Text.Locate (10, 25)
put "Type the number of items you want to purchase:"
Text.Locate (11, 25)
get purchase4
elsif x >= 20 and y >= 30 and x <= 120 and y <= 90 then
current := 1
end if

elsif (current = 7) then


Text.Locate (10, 10)

put purchase
put purchase1
put purchase2
put purchase3
put purchase4

put purchase
end if

This is the code.. i used the if structure to make this code... but whenever i try opening any of the thing it will just cls... also if i delete the if structure on if (current = 1) then
%category
then it would open.. but i can't get back to category to let them open the checkout page to see the purchase they made... also it won't even show the
(Text.Locate (10, 25)
put "Type the number of items you want to purchase:"
Text.Locate (11, 25)
get purchase)
Won't show up... could someone tell me what might be the problem... or give me a suggestion?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Jan 23, 2011 1:33 pm   Post subject: RE:My final project but having problem with it...

There are 8 instances of "cls" on this page, and 12 of "View.Update" -- I'll make a guess that those were not well organized and you're either missing something or have too much of something.

Remove offscreenonly for the purposes of debugging your code. Follow the code-flow, to see if it does what you expect it to. Using put statements as soon as you enter different blocks is an excellent way to keep track of where the program is actually at.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Raknarg




PostPosted: Thu Feb 17, 2011 8:52 pm   Post subject: RE:My final project but having problem with it...

Ok, so if you are actually going to try and use the offscreenonly, you only need to use the View.Update ONCE, after your draw statements, thats it. One thing that newbies do is they spam thir codes with cls and viewupdates, which will conflict achother i.e. if you use View.Update after cls, it will show the cls. A.k.a nothing. Then if you try to draw something and view.update, it'll show the cls and the draw. Same problem as not having it at all. Make it efficient.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: