when using:
pic=Image.createEmpty(5,5 )
pic:clear(color)
can you somehow use it to make a circle instead of an square?
Printable View
when using:
pic=Image.createEmpty(5,5 )
pic:clear(color)
can you somehow use it to make a circle instead of an square?
Ok ive got everything working fine exept for the random part. it keeps giving the same number over and over. i put
math.randomseed(os.time() )
in and everything.
Code:math.randomseed(os.time() )
background = Image.load("background.PNG")
player = Image.load("ball.PNG")
block = Image.load("block.PNG")
space = Image.load("white.PNG")
--Variables
XAxis=100
YAxis=100
L1=0
System.usbDiskModeActivate()
while true do
screen:clear()
screen:blit(0, 0, background, false)
screen:blit(XAxis, YAxis, player)
pad = Controls.read()
if pad:start() then
break
end
if pad:right() then
if XAxis<448 then
XAxis=XAxis+6
else
XAxis=448
end
end
if pad:left() then
if XAxis>0 then
XAxis=XAxis-6
else
XAxis=0
end
end
--First Line
Line1 = {0,0,0,0,0,0,0,0}
if L1==0 then
Line1[1]=math.random(0,1)
Line1[2]=math.random(0,1)
Line1[3]=math.random(0,1)
Line1[4]=math.random(0,1)
Line1[5]=math.random(0,1)
Line1[6]=math.random(0,1)
Line1[7]=math.random(0,1)
Line1[8]=math.random(0,1)
YVars1=272
L1=1
end
if L1==1 then
YVars1=YVars1-2
if Line1[1]==0 then
screen:blit(0, YVars1, block)
end
if Line1[1]==1 then
screen:blit(0, YVars1, space)
end
if Line1[2]==0 then
screen:blit(60, YVars1, block)
end
if Line1[2]==1 then
screen:blit(60, YVars1, space)
end
if Line1[3]==0 then
screen:blit(120, YVars1, block)
end
if Line1[3]==1 then
screen:blit(120, YVars1, space)
end
if Line1[4]==0 then
screen:blit(180, YVars1, block)
end
if Line1[4]==1 then
screen:blit(180, YVars1, space)
end
if Line1[5]==0 then
screen:blit(240, YVars1, block)
end
if Line1[6]==1 then
screen:blit(300, YVars1, space)
end
if Line1[6]==0 then
screen:blit(300, YVars1, block)
end
if Line1[7]==1 then
screen:blit(360, YVars1, space)
end
if Line1[7]==0 then
screen:blit(360, YVars1, block)
end
if Line1[8]==1 then
screen:blit(420, YVars1, space)
end
if Line1[8]==0 then
screen:blit(420, YVars1, block)
end
screen.flip()
end
if YVars1==0 then
YVars1=272
L1=0
end
end
arg i've been trying to get some of pspmillionaires code to work with mine to get a ball to duplicate but it won heres what i'm using:
as of his original code works but now this one won't can someone tell me why and heres the errors i'm getting:Code:--Create colors
green=Color.new(0,255,0)
white = Color.new(255,255,255)
bluepaintball=Image.load("C:/Documents and Settings/tim/pspaintball/bluepaintball.png")
--Variables
oldpad = Controls.read()
currentBullet = 0
xy={}
xy[1]={x=0,y=10}
--Create Array for Bullets
paintballs = {}
for a = 1,5 do
paintballs[a] = { pic = bluepaintball , firing = false,x = xy[1].x + 32, y = xy[1].y + 16 }
end
--Functions
function bulletSetup()
--Increase the current bullet by one, or reset it to 1
if currentBullet < 5 then
currentBullet = currentBullet + 1
else
currentBullet = 1
end
paintballs[currentBullet].firing = true
end
function bulletFire()
for i = 1,5 do
if paintballs[i].firing == true then
paintballs[i].x = paintballs[i].x + 10 end
screen:blit(paintballs[i].x,paintballs[i].y,paintballs[i].pic)
end
if paintballs[i].x>480 then paintballs[i].firing=false
end
end
end
--Main Loop
while true do
pad = Controls.read()
screen:clear()
if pad:cross() and oldpad:cross() ~= pad:cross() then
bulletSetup()
end
bulletFire()
screen.waitVblankStart()
screen.flip()
oldpad = pad
end
the boldin end if i have that in it says:
error: C:\Documents and Settings\""\pspaintball\t ry.lua:43: <eof> expected near
`end'
and if i take it out:
error: C:\Documents and Settings\""\pspaintball\t ry.lua:40: attempt to index field `?' (a nil value)
so can someone tell me why it wont work=-)
edit: well i should mention that the other code i worked on:
works in duplicating it the first 5 times though and then it doesnt do it any longer=-( i hope some1 can help meCode:black=Color.new(0,0,0)
green=Color.new(0,255,0)
bluepaintball=Image.load("C:/Documents and Settings/tim/pspaintball/bluepaintball.png")
oldpad=Controls.read()
currentpaintball=0
ballsxy={}
ballsxy[1]={x=0,y=10}
paintballs={}
for i=1,5 do
paintballs[i]={pic=bluepaintball,firing=false,x=ballsxy[1].x,y=ballsxy[1].y}
end
function paintballsetup()
if currentpaintball < 5 then
currentpaintball = currentpaintball + 1
else
currentpaintball = 1
end
paintballs[currentpaintball].firing=true
end
function paintballfire()
for a=1,5 do
if paintballs[a].firing==true then
paintballs[a].x=paintballs[a].x+10
screen:blit(paintballs[a].x, paintballs[a].y, paintballs[a].pic)
end
if paintballs[a].x>480 then paintballs[a].firing=false
end
end
end
while true do
pad=Controls.read()
screen:clear()
if pad:cross() and oldpad:cross() ~=pad:cross() then paintballsetup()
end
paintballfire()
screen:print(10,10,"paintball 1: ".. tostring(paintballs[1].firing),green)
screen:print(10,20,"paintball 2: "..tostring(paintballs[2].firing),green)
screen:print(10,30,"paintball 3: "..tostring(paintballs[3].firing),green)
screen:print(10,40,"paintball 4: "..tostring(paintballs[4].firing),green)
screen:print(10,50,"paintball 5: "..tostring(paintballs[5].firing),green)
screen.waitVblankStart()
screen.flip()
oldpad=pad
end
you have it going to the c drive,,
just put pspaintball folder in beside script.lua, and change C:\Documents and Settings\""\pspaintball\ to just pspaintball/whatever
no i'm using luaplayerwindows instead of loading up my psp everytime i wanna test the code
still do what i said
trust me it doesn't work in order to load images(though your pc) you have to call it's direct path even then it works fine and that isn't my question
it works just like he was saying. i do it that way.
I'm asuming you can use a variable for x and y coorodinates, like in this example:
I guess i'm wrong, is there any way to do this?Code:white = Color.new(255,255,255)
textX = 100
texty = 300
screen:print(textX, textY, "Hello World", white)
screen.flip()
while true do
screen.waitVblankStart()
end
no you're not wrong, you're right! And the code should work