Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / A workbench for placing graphic on the screen - snippet

Author
Message
Prizma tica
18
Years of Service
User Offline
Joined: 27th Oct 2006
Location:
Posted: 27th Oct 2006 13:43
Hello everyone!
I made a workbench for finding x and y positions on the screen.

unfortunately my skills in programming are not so good so i borrowed some snippets from the forum and put them together. Of course i added some codes myself.
I would like to ask for litlle help.

This screen is sized 1280x800
It took me half a day to write a code for grids (Lines).
I know that somehow i could make it easier with less lines but i couldnt figure it how.

In this program you see grid system and you see mouse x,y positions in two places.
Top left of the screen and near your mousepointer.
There is a litlle box following the mouse too so you can precise your position on the screen even better.

i would like to develop this.
For example:
,to make grid apear on/off the screen,
to make it possible to change screensize to 1024x768, 800x600, etc...
and of course to make this code with lines a litlle easier.
In exchange you will all have a nice workbench for position of Graphics on the screen =).

Thanx!
Prizmatica
Prizma tica
18
Years of Service
User Offline
Joined: 27th Oct 2006
Location:
Posted: 27th Oct 2006 14:59
It didnt work with a code i try again....

Attachments

Login to view attachments
Prizma tica
18
Years of Service
User Offline
Joined: 27th Oct 2006
Location:
Posted: 27th Oct 2006 15:21
OK i got to place code here, dont know why it doesnt work when i upload the code:

`This sets up the program
set display mode 1280,800,32
sync on
sync rate 0
`=====================================
remstart
GOSUB LOAD_MEDIA
` ==============================
LOAD_MEDIA: `loading animations in to the program (not on screen yet)
load animation "whatever.gif",1
w=animation width(1)
h=animation height(1)
play animation to image 1,1,0,1,w,h
LOOP ANIMATION 1
load animation "whatever.avi",2
w=animation width(2)
h=animation height(2)
play animation to image 2,2,0,1,w,h
LOOP ANIMATION 2
` ==============================
remend
Grid_TileWidth=5 `Width of the litlle box that follows the mouse
Grid_Tileheight=5 `Height of the litlle box that follows the mouse

` ==============================

Do
cls 0
GRIDS()`call function GRIDS()
remstart
X1=446 `X - position of the first animation
Y1=0 `Y - position of the first animation
SPRITE 2,X1,Y1,2 `Paste first animation on screen
X2=595 `X - position of the seccond animation
Y2=205 `Y - position of the seccond animation
SPRITE 1,X2,Y2,1 `Paste seccond animation on the screen
remend
` ==============================
INK RGB(255,255,0),RGB(0,0,0)
`SETUP MOUSE COORDINATES (for the top left area of the screen)
xpos=mousex()
ypos=mousey()
PRINT ""
PRINT ""
print "X - KOORDINATA = ",xpos `this prints mouse X position on the top left of the screen
print "Y - KOORDINATA = ",ypos `this prints mouse Y position on the top left of the screen

INK RGB(255,0,0),RGB(0,0,0)
X=MOUSEX()
Y=MOUSEY()
SET TEXT OPAQUE
TEXT X-50,Y-50,STR$(MOUSEX())
TEXT X-70,Y-50,"X=" `This prints mouse X position near the mouse cursor
TEXT X-50,Y-25,STR$(MOUSEY())
TEXT X-70,Y-25,"Y=" `This prints mouse Y position near the mouse cursor


` ==============================
remstart
`DISPLAY ANIMATION SIZE
INK RGB(0,255,0),RGB(0,0,0)
AW=ANIMATION WIDTH(1)
AH=ANIMATION HEIGHT(1)
PRINT ""
PRINT ""
PRINT "ANIMATION 1 = ",AW," X ",AH
PRINT ""
AW=ANIMATION WIDTH(2)
AH=ANIMATION HEIGHT(2)
PRINT ""
PRINT ""
PRINT "ANIMATION 2 = ",AW," X ",AH
PRINT ""
remend
` ==============================
`SETUP GRID FOR MOUSE (litlle box)
Grid_Xpos=(xpos/grid_tilewidth)*grid_tilewidth
Grid_Ypos=(ypos/grid_tileheight)*grid_tileheight
Grid_xpos2=Grid_xpos+grid_tilewidth
Grid_ypos2=Grid_ypos+grid_tileheight
` ==============================
box Grid_xpos,Grid_ypos,Grid_xpos2,Grid_ypos2
` ==============================
sync
loop
` ==============================

FUNCTION GRIDS()
`SETTING UP THE GRIDS FOR 1280x800 MELLANRUM=20
`--------------------------------------------------
INK RGB(128,128,128),RGB(0,0,0)
`VERTICAL LINES
A=20 `=20
B=A+A `=40
C=B+A `=60
D=C+A `=80
E=D+A `=100
LINE 0,0,0,799:LINE A,0,A,799:LINE B,0,B,799:LINE C,0,C,799:LINE D,0,D,799
LINE E,0,E,799:LINE E+A,0,E+A,799:LINE E+B,0,E+B,799:LINE E+C,0,E+C,799:LINE E+D,0,E+D,799
LINE E*2,0,E*2,799:LINE E*2+A,0,E*2+A,799:LINE E*2+B,0,E*2+B,799:LINE E*2+C,0,E*2+C,799:LINE E*2+D,0,E*2+D,799
LINE E*3,0,E*3,799:LINE E*3+A,0,E*3+A,799:LINE E*3+B,0,E*3+B,799:LINE E*3+C,0,E*3+C,799:LINE E*3+D,0,E*3+D,799
LINE E*4,0,E*4,799:LINE E*4+A,0,E*4+A,799:LINE E*4+B,0,E*4+B,799:LINE E*4+C,0,E*4+C,799:LINE E*4+D,0,E*4+D,799
LINE E*5,0,E*5,799:LINE E*5+A,0,E*5+A,799:LINE E*5+B,0,E*5+B,799:LINE E*5+C,0,E*5+C,799:LINE E*5+D,0,E*5+D,799
LINE E*6,0,E*6,799:LINE E*6+A,0,E*6+A,799:LINE E*6+B,0,E*6+B,799:LINE E*6+C,0,E*6+C,799:LINE E*6+D,0,E*6+D,799
LINE E*7,0,E*7,799:LINE E*7+A,0,E*7+A,799:LINE E*7+B,0,E*7+B,799:LINE E*7+C,0,E*7+C,799:LINE E*7+D,0,E*7+D,799
LINE E*8,0,E*8,799:LINE E*8+A,0,E*8+A,799:LINE E*8+B,0,E*8+B,799:LINE E*8+C,0,E*8+C,799:LINE E*8+D,0,E*8+D,799
LINE E*9,0,E*9,799:LINE E*9+A,0,E*9+A,799:LINE E*9+B,0,E*9+B,799:LINE E*9+C,0,E*9+C,799:LINE E*9+D,0,E*9+D,799
LINE E*10,0,E*10,799:LINE E*10+A,0,E*10+A,799:LINE E*10+B,0,E*10+B,799:LINE E*10+C,0,E*10+C,799:LINE E*10+D,0,E*10+D,799
LINE E*11,0,E*11,799:LINE E*11+A,0,E*11+A,799:LINE E*11+B,0,E*11+B,799:LINE E*11+C,0,E*11+C,799:LINE E*11+D,0,E*11+D,799
LINE E*12,0,E*12,799:LINE E*12+A,0,E*12+A,799:LINE E*12+B,0,E*12+B,799:LINE E*12+C,0,E*12+C,799:LINE E*12+D-1,0,E*12+D-1,799
`--------------------
`HORIZONTAL LINES
LINE 0,0,1279,0:LINE 0,A,1279,A:LINE 0,B,1279,B:LINE 0,C,1279,C:LINE 0,D,1279,D
LINE 0,E,1279,E:LINE 0,E+A,1279,E+A:LINE 0,E+B,1279,E+B:LINE 0,E+C,1279,E+C:LINE 0,E+D,1279,E+D
LINE 0,E*2,1279,E*2:LINE 0,E*2+A,1279,E*2+A:LINE 0,E*2+B,1279,E*2+B:LINE 0,E*2+C,1279,E*2+C:LINE 0,E*2+D,1279,E*2+D
LINE 0,E*3,1279,E*3:LINE 0,E*3+A,1279,E*3+A:LINE 0,E*3+B,1279,E*3+B:LINE 0,E*3+C,1279,E*3+C:LINE 0,E*3+D,1279,E*3+D
LINE 0,E*4,1279,E*4:LINE 0,E*4+A,1279,E*4+A:LINE 0,E*4+B,1279,E*4+B:LINE 0,E*4+C,1279,E*4+C:LINE 0,E*4+D,1279,E*4+D
LINE 0,E*5,1279,E*5:LINE 0,E*5+A,1279,E*5+A:LINE 0,E*5+B,1279,E*5+B:LINE 0,E*5+C,1279,E*5+C:LINE 0,E*5+D,1279,E*5+D
LINE 0,E*6,1279,E*6:LINE 0,E*6+A,1279,E*6+A:LINE 0,E*6+B,1279,E*6+B:LINE 0,E*6+C,1279,E*6+C:LINE 0,E*6+D,1279,E*6+D
LINE 0,E*7,1279,E*7:LINE 0,E*7+A,1279,E*7+A:LINE 0,E*7+B,1279,E*7+B:LINE 0,E*7+C,1279,E*7+C:LINE 0,E*7+D,1279,E*7+D
LINE 0,E*8-1,1279,E*8-1
ENDFUNCTION

Thanx
Prizmatica
Prizma tica
18
Years of Service
User Offline
Joined: 27th Oct 2006
Location:
Posted: 27th Oct 2006 16:17
Here is how it looks like right now:

Attachments

Login to view attachments
sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 28th Oct 2006 01:08
very nice!!!

Login to post a reply

Server time is: 2024-11-22 23:24:46
Your offset time is: 2024-11-22 23:24:46