 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
glynnder
Joined: 04 Sep 2005 Posts: 35
|
Posted: Sun Mar 05, 2006 12:11 am Post subject: SORRY NOOB-A-RIFFIC - Cursor |
|
|
Im seriously new to lua and was wondering if there was a code that made a cursor (cursor.png) move around the sreen with the analog stick and then when you hover over a button and hit x it will go to the thing that button does?
Also are menu's like in ttlde's file quite hard/easy to make?
here's my code:
| Code: | -- PSPOffice
--created by Glynnder
dblue = Color.new(0, 0, 255)
red = Color.new(230, 0, 0)
pink = Color.new(255, 0 , 153)
blue = Color.new(0 , 153, 255)
orange = Color.new(255, 102, 0)
gray = Color.new(153, 153, 153)
black = Color.new(0 , 0 , 0)
white = Color.new(255, 255, 255)
screen:print(194, 136, "loading: 0%", red)
screen.flip()
background = Image.load("images/home.png")
screen:clear()
screen:print(194, 136, "loading 20%", pink)
screen. flip()
pstype = Image.load("images/pstypebutton.png")
--created by glynnder
screen:clear()
screen:print(194, 136, "Loading: 40%", pink)
screen.flip()
psdraw = Image.load("images/psdrawbutton.png")
x1 = 0 ; x0 = 0 ; y1 = 0 ; y0 = 0
screen:clear()
screen:print(194, 136, "Loading: 60%", pink)
screen.flip()
pscalc = Image.load("images/pscalcbutton.png")
screen:clear()
screen:print(194, 136, "Loading: 80%", pink)
screen.flip()
links = Image.load("images/linksbutton.png")
screen:clear()
screen:print(194, 136, "Loading: 90%", pink)
screen.flip()
bg2 = Image.load("images/apps.png")
cursor = Image.load("images/cursor.png")
screen:clear()
screen:print(194, 136, "Loading: 100%", pink)
screen.flip()
screen.waitVblankStart(60)
screen.flip()
while true do
screen:blit(0, 0, background, false)
screen:blit(30, 150, pstype, true)
screen:blit(100, 195, pscalc, true)
screen:blit(285, 195, psdraw, true)
screen:blit(355, 150, links, true)
time = os.time()
dateString = os.date("%c")
screen:print(1, 1, os.date(), red)
dateFields = os.date("*t")
hour = dateFields.hour
if hour < 10 then
hour = "0" .. hour
end
min = dateFields.min
if min < 10 then
min = "0" .. min
end
sec = dateFields.sec
if sec < 10 then
sec = "0" .. sec
end
screen:print(30, 260, "Press 'Start' to quit", blue)
screen:print(400, 1, "Batt:", red)
if (System.powerIsLowBattery()) == true then
screen:print(440, 1, tostring(System.powerGetBatteryLifePercent()) .. "%", blue)
else screen:print(450, 1, tostring(System.powerGetBatteryLifePercent()) .. "%", red)
end
if (System.powerIsBatteryCharging()) == true then
screen:print(457, 1, "+", red) end
screen:print(300, 260, "'Select' = Screenshot", white)
pad = Controls.read()
screen.flip()
if pad:start() then
break
end
if pad:select() then
screen:save("screenshot.jpg")
function analogS()
pad = Controls.read()
dx = pad:analogX()
if math.abs(dx) > 32 then
x0 = x1 + dx / 64
end
dy = pad:analogY()
if math.abs(dy) > 32 then
y0 = y1 + dy / 64
end
end
screen:blit(x0, y0, cursor, true)
screen.flip()
end
end |
|
|
| Back to top |
|
 |
wekilledbambi03
Joined: 15 Oct 2005 Posts: 31
|
Posted: Sun Mar 05, 2006 11:29 am Post subject: Re: SORRY NOOB-A-RIFFIC - Cursor |
|
|
if this is where your images are for the icons
| Code: |
screen:blit(30, 150, pstype, true)
screen:blit(100, 195, pscalc, true)
screen:blit(285, 195, psdraw, true)
screen:blit(355, 150, links, true)
|
you can use these coordinates to make yourself a "box". for the purpose of making this simple ill pretend your icons are 10x10. and your cursor is at x0, y0. now well use the psptype iscon. well say
| Code: |
if x0>30 and x0<40 and y0>150 and y0 < 160 and pad:cross()
then whatever
end
|
there may be different or better ways to do it but thats how id do it. |
|
| Back to top |
|
 |
glynnder
Joined: 04 Sep 2005 Posts: 35
|
Posted: Sun Mar 05, 2006 5:17 pm Post subject: |
|
|
OOk, the solves the clicking problem, but its still doesn't move!
Can anyone help with that? |
|
| Back to top |
|
 |
JorDy
Joined: 11 Dec 2005 Posts: 121
|
Posted: Sun Mar 05, 2006 9:06 pm Post subject: |
|
|
| Code: | pad = Controls.read()
dx = pad:analogX()
if math.abs(dx) > 32 then
x0 = x0 + dx / 64
end
dy = pad:analogY()
if math.abs(dy) > 32 then
y0 = y0 + dy / 64
end |
That should get the cursor moving. im sure you can work it out from there |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|