Adding custom image to cursor tut

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
Stretch Arm-Strong
Posts: 5
Joined: Tue Oct 11, 2005 9:24 am

Adding custom image to cursor tut

Post by Stretch Arm-Strong »

I took the cursor script, and used it...but than im like, how cool would it be to slap a pic. of myself or a pic. of my teacher for instance haha, and be able to draw all over that....instead of having CANVAS = CLEAR(WHITE) i tried the following....


+++++++++++++++++++++++++++++++++++++++++++

System.usbDiskModeActivate()

pink = Color.new(255, 0, 255);
white = Color.new(255, 255, 255);



canvas = Image.load("background.png")
canvas:background.png

brush = {}
eraser = {}

x0 = 0

y0 = 0
x1 = 0
y1 = 0
while true do
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
if pad:cross() then
canvas:drawLine(x0, y0, x1, y1, white)
end
x1 = x0
y1 = y0
screen:blit(0, 0, canvas, 0, 0, canvas:width(), canvas:height(), false)
screen:drawLine(x1 - 5, y1, x1 + 5, y1, pink)
screen:drawLine(x1, y1 - 5, x1, y1 + 5, pink)
screen.waitVblankStart()
screen.flip()
if pad:start() then break end
if pad:select() then screen:save("screenshot.tga") end
end

++++++++++++++++++++++++++++++++++++++++


what did i do wrong and what do i do to fix it

--Stretch Arm-Strong
User avatar
JoshDB
Posts: 87
Joined: Wed Oct 05, 2005 3:54 am

Post by JoshDB »

x1 = 240
y1 = 136

X_MAX = 480
Y_MAX = 272

X_MIN = 0
Y_MIN = 0

speed = 32

cursor = Image.load("CURSOR.png")

function CursorPos()
dx = button:analogX()
if math.abs(dx) > 32 then
x1 = x1 + dx / speed
if x1 > X_MAX then
x1 = X_MAX
end
if x1 < X_MIN then
x1 = X_MIN
end
end
dy = button:analogY()
if math.abs(dy) > 32 then
y1 = y1 + dy / speed
if y1 > Y_MAX then
y1 = Y_MAX
end
if y1 < Y_MIN then
y1 = Y_MIN
end
end
end

function PSPEnvCreate:Render()
screen:blit(x1, y1, cursor)
end

while true do
screen:clear()
button = Controls.read()
CursorPos()
Render()
screen.waitVblankStart(1)
screen.flip()
end
Stretch Arm-Strong
Posts: 5
Joined: Tue Oct 11, 2005 9:24 am

Post by Stretch Arm-Strong »

i didnt want the cursor to be a pic. i wanted the canvas to be a pic... thnx for that anyway
Stretch Arm-Strong
Posts: 5
Joined: Tue Oct 11, 2005 9:24 am

Post by Stretch Arm-Strong »

FIGURED IT OUT
Post Reply