Zooming for a Scope!!!! HELP NEEDED
Author |
Message |
B-Man 31
|
Posted: Sat Jan 03, 2009 12:43 pm Post subject: Zooming for a Scope!!!! HELP NEEDED |
|
|
I am making a FPS type shooter for my ISU and i cant seem to get the scoping down., what i am trying to do is that when you click the right mouse button the background will zoom in by 2 or 3 times the size (haven't decided that yet). i have it zooming but i cant get the cross hair to stay in the same position. By that i mean that when i zoom with the cross hair in the middle, once the background has been enlarged, the cross hair is not in the middle any more. It would be greatly appreciated if i could get some help with this. thank you
here is the code and i also attached the turing file with the BG picture
Turing: |
setscreen ("graphics:600,400,offscreenonly,nocursor")
buttonchoose ("multibutton")
%NOTE
% This is only the zooming part of my program, the scope is not drawn infront
% of the zoomed picture, i would just like to get this part lined up so i can
% implement it in the program after
var bg : int := Pic.FileNew ("test2.bmp") %the original BG
var bgz : int := Pic.Scale (bg, Pic.Width (bg ) * 2, Pic.Height (bg ) * 2) %the new larger BG
var bgX, bgY, bgzY, bgzX, mx, my, button, left, right, middle, scope : int
var hasScoped : boolean := false
%bgX and bgY are the normal background X and Y
bgX := (maxx - Pic.Width (bg )) div 2
bgY := (maxy - Pic.Height (bg )) div 2
%%bgzX and bgzY are the zoomed background X and Y
bgzX := ((maxx - Pic.Width (bg )) div 2) * 3
bgzY := ((maxy - Pic.Height (bg )) div 2) * 3
Pic.Draw (bg, bgX, bgY, picCopy)
%The area you can see, so you dont go beyond the borders of the picture
procedure viewArea
if scope = 1 then
if bgzX >= 0 then
bgzX := 0
end if
if bgzX < - 1400 then
bgzX := - 1400
end if
if bgzY > 0 then
bgzY := 0
end if
if bgzY < - 1200 then
bgzY := - 1200
end if
elsif scope = 0 then
if bgX >= 0 then
bgX := 0
end if
if bgX < - 350 then
bgX := - 350
end if
if bgY > 0 then
bgY := 0
end if
if bgY < - 400 then
bgY := - 400
end if
end if
end viewArea
procedure scopes
scope := 1
end scopes
scope := 0
loop
mousewhere (mx, my, button )
left := button mod 10
middle := (button - left ) mod 100
right := button - middle - left
%the mouse moving settings
%mx and my are mouse X and mouse Y
if mx > 325 and mx <= 600 then
if scope = 0 then
bgX - = 10
elsif scope = 1 then
bgzX - = 10
end if
viewArea
end if
if mx < 275 and mx >= 0 then
if scope = 0 then
bgX + = 10
elsif scope = 1 then
bgzX + = 10
end if
viewArea
end if
if my > 225 and my <= 400 then
if scope = 0 then
bgY - = 10
elsif scope = 1 then
bgzY - = 10
end if
viewArea
end if
if my < 175 and my >= 0 then
if scope = 0 then
bgY + = 10
elsif scope = 1 then
bgzY + = 10
end if
viewArea
end if
%Drawing cross hair
drawline (maxx div 2, maxy div 2, (maxx div 2) + 10, maxy div 2, red)
drawline (maxx div 2, maxy div 2, (maxx div 2) - 10, maxy div 2, red)
drawline (maxx div 2, maxy div 2, maxx div 2, (maxy div 2) + 10, red)
drawline (maxx div 2, maxy div 2, maxx div 2, (maxy div 2) - 10, red)
if scope = 0 then
Pic.Draw (bg, bgX, bgY, picCopy)
elsif scope = 1 then
Pic.Draw (bgz, bgzX, bgzY, picCopy)
end if
if right = 100 and hasScoped = true then
scope := 0
hasScoped := false
end if
if right = 100 and hasScoped = false then
scopes
hasScoped := true
end if
View.Update
delay (100)
end loop
|
Description: |
This is the Turing File and the BG picture so you can run and edit it. |
|
Download |
Filename: |
BG ZOOM.zip |
Filesize: |
56.01 KB |
Downloaded: |
98 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
BigBear
|
Posted: Sun Mar 01, 2009 11:09 am Post subject: Re: Zooming for a Scope!!!! HELP NEEDED |
|
|
I think I see what you mean if your mouse is not inside the rectangle and you zoom in it becomes inside the rectangle.
I was able to put it in the middle and zoom in and zoom out and it would stay the same.
Also I think you should have it so when your cross hair is in the rectangle it no longer tries to scroll the screen, so you put the mouse on the spot more or less making it easier to aim.
You should put your cross hair after you check if their are zoomed in and which picture to draw.
I added
Turing: | drawoval (mx, my, 10, 10, blue)
drawline (mx - 12, my - 12, mx + 12, my + 12, blue)
drawline (mx + 12, my - 12, mx - 12, my + 12, blue) |
before the View.Update thinking you didn't have a cross hair.
|
|
|
|
|
|
Lekegolo killer
|
Posted: Mon Mar 02, 2009 12:08 pm Post subject: Re: Zooming for a Scope!!!! HELP NEEDED |
|
|
i think you have it set to center on the center of the image when you zoom...
TURING
%%bgzX and bgzY are the zoomed background X and Y
bgzX := ((maxx - Pic.Width (bg)) div 2) * 3
bgzY := ((maxy - Pic.Height (bg)) div 2) * 3
Pic.Draw (bg, bgX, bgY, picCopy)
when you should be having it zoom on the mouse curser? i could be completely wrong but...
TURING
bgzX := ((maxx - Pic.Width (bg)) div 2) * 3
bgzY := ((maxy - Pic.Height (bg)) div 2) * 3
Pic.Draw (bg, mousex, mouseY, picCopy)
sumthing like that i think (that's not the actual coding obviusly i am to nub to know how you would do this, probably another variable or mouse.where or whateva).
|
|
|
|
|
|
|
|