screen:drawLine(-10, -10, 100, 50, red) ie off screen

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

Moderators: Shine, Insert_witty_name

Post Reply
jimjamjahaa
Posts: 17
Joined: Mon Oct 03, 2005 5:00 am

screen:drawLine(-10, -10, 100, 50, red) ie off screen

Post by jimjamjahaa »

will result in the same as a screen:drawLine(0, 0, 100, 50, red)

my question, how do you make it so that the line goes in the right place?

ie to the edge of the screen as though it would end at -10, -10. im new to lua and building off of the paint tutorial :). if you need to see my code i can post it for you :)
Giuliano
Posts: 78
Joined: Tue Sep 13, 2005 10:26 am

Post by Giuliano »

Well an easy way is to use absolute value to shorten the width and offset the x.. for example..

Pseudo Code:

Code: Select all

x1=-20

offsetx=0
if &#40;x1<0&#41; then
 offsetx=math.abs&#40;x1&#41;
end

-- do the same thing for Y

screen&#58;drawline&#40;x1+offsetx,y1+offsety,x2-offsetx,y2-offsetx,red&#41;
This also works when you are blitting outside of the screen. I REALLY don't recommend ever using negative values when drawing anything in Lua because sometimes it might work but not all the time. I noticed that in my game, so offset like I showed above:)
jimjamjahaa
Posts: 17
Joined: Mon Oct 03, 2005 5:00 am

Post by jimjamjahaa »

hmm i see where you are coming from, but that seems like a lot of hassle, especially if i have much larger models being drawn etc.

take a look at this

http://host-a.net/getfile.php?usern=mon ... e=ship.zip (left click)

move the ship off to the side and you will see what im talking about. controls are x fire ^ change arc and l + r aim. anyone who can help me will be hailed as a god in the credits of this game :D

dont comment on the state of my code.... :P
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

Currently there is no real clipping implemented, just a if (x<0) x=0 and the like, so it might looks strange, if you are using coordinates which are not on-screen or on-image. I've added it to the TODO list at http://wiki.ps2dev.org/psp:lua_player:todos
jimjamjahaa
Posts: 17
Joined: Mon Oct 03, 2005 5:00 am

Post by jimjamjahaa »

aha! i see.

thx again shine, you are the most helpful person ever :D

i will have to implement my own clipping etc.
Post Reply