game help please!!!
Author |
Message |
RoCkEr
|
Posted: Sat Nov 04, 2006 9:05 pm Post subject: game help please!!! |
|
|
here is my code for my game
iew.Set ("graphics:max,max")
var counter : int := Pic.FileNew ("counter copy.jpg")
var current_tool : int := 0
var mx, my, mb : int
var font : int := Font.New ("sans serif:24:bold")
var lvl1 : int := Pic.FileNew ("SmallInferno.jpg")
var lvl2 : int := Pic.FileNew ("SmallItaly.jpg")
var lvl3 : int := Pic.FileNew ("SmallOffice.jpg")
var lvl4 : int := Pic.FileNew ("SmallMilitia.jpg")
var lvl5 : int := Pic.FileNew ("Smallprodigy.jpg")
var level:int:=0
var level1:int:= Pic.FileNew ("inferno.jpg")
var level2:int:= Pic.FileNew ("Italy.jpg")
var level3:int:= Pic.FileNew ("Office1.jpg")
var level4:int:= Pic.FileNew ("Militia.jpg")
var level5:int:= Pic.FileNew ("prodigy.jpg")
loop
Pic.Draw (counter, 0, 0, picCopy) %full screen
exit when hasch
Font.Draw ("Press enter to start", 50, 200, font, brightgreen)
end loop
cls
drawfillbox (0, 0, maxx, maxy, black)
drawbox (200, 200, 150, 150, red)
drawbox (200, 350, 150, 300, red)
drawbox (200, 400, 150, 450, red)
drawbox (800, 200, 750, 150, red)
drawbox (800, 350, 750, 300, red)
Pic.Draw (lvl1, 150, 130, picCopy)
Pic.Draw (lvl2, 110, 280, picCopy)
Pic.Draw (lvl3, 150, 400, picCopy)
Pic.Draw (lvl4, 750, 300, picCopy)
Pic.Draw (lvl5, 750, 150, picCopy)
loop
mousewhere (mx, my, mb)
if mb = 1 and mx > 200 and my > 200 and mx < 150 and my < 150 then
Pic.Draw (level1,0,0,picCopy)
elsif mb = 1 and mx > 200 and my > 350 and mx < 150 and my < 300 then
Pic.Draw (level2,0,0,picCopy)
elsif mb = 1 and mx > 200 and my > 400 and mx < 150 and my < 400 then
Pic.Draw (level3,0,0,picCopy)
elsif mb = 1 and mx > 800 and my > 200 and mx < 750 and my < 300 then
Pic.Draw(level4,0,0,picCopy)
elsif mb = 1 and mx > 800 and my > 350 and mx < 750 and my < 300 then
Pic.Draw(level5,0,0,picCopy)
exit
end if
end loop
i am trying to get it so if i click on one of the small pic it will open the level can someone please help me. Thank you. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
jamonathin
|
Posted: Sat Nov 04, 2006 9:28 pm Post subject: (No subject) |
|
|
You're going to need some variables, or at least some co-ordinates that represent the lower left hand corner of your picture. So use that to your advantage and incorporate that into your mousewhere 'if' statements. Like such:
Turing: |
var mx, my, mb : int %mouse variables
var x, y: int := 100 %lower left of pic variables
var pic : int := Pic.FileNew("SomeRandomPic.jpg")
Pic.Draw (pic, x, y, picCopy)
loop
mousewhere(mx, my, mb )
if mx >= x and my >= y and mx <= (x + Pic.Width (pic )) and my <= (y + Pic.Height(pic )) and mb = 1 then
put "You have clicked inside the pic,\n"
put "Now run whatever it is you want to."
exit
end if
end loop |
This uses Pic.Width and Pic.Height. They pretty much do exactly what you would think. They are integer values of the Width and Height of the pic. They'll make doing something like this much easier.
Get used to using variables to represent co-ordinates, it will make everything much easier to manipulate. |
|
|
|
|
|
RoCkEr
|
Posted: Sat Nov 04, 2006 9:44 pm Post subject: (No subject) |
|
|
Im in grade 10 so im not that filimar with the program so can you give me a simpler forum of it? |
|
|
|
|
|
ericfourfour
|
Posted: Sat Nov 04, 2006 10:47 pm Post subject: (No subject) |
|
|
That is just about as simple as it gets. How much of Turing do you know? You will want to see here if that question was serious.
The only way it could have been simpler is if jamonathin made an x2 and y2 variable which would have been the right side and top of the picture. |
|
|
|
|
|
RoCkEr
|
Posted: Mon Nov 06, 2006 4:15 pm Post subject: (No subject) |
|
|
i know quite a bit of it but i just cant get it to work ive tried about everyhting i know |
|
|
|
|
|
Tony
|
Posted: Mon Nov 06, 2006 4:33 pm Post subject: (No subject) |
|
|
RoCkEr wrote: ive tried about everyhting i know
Have you tried running jamonathin's code? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
batman
|
Posted: Tue Nov 07, 2006 6:58 pm Post subject: Code |
|
|
First of all I think you should try to understand jamonathins code and if you dont understand a spefic part of it ask questions. Second try to implimet his code into yours. Third of all, when I was looking for ur code I recommend especially when posting for help that you add comments making it easier for people to read ur code and get a code idea of what it is ur doing. |
|
|
|
|
|
|
|