thanks, i have this now, but my enemy wont move.
Code:screen:blit(enemy.x,enemy.y,enemy1)
end
if enemy.x > 0 then
enemy.x = enemy.x + 10
end
screen:blit(enemy.x,enemy.y,enemy1)
screen.flip()
Printable View
thanks, i have this now, but my enemy wont move.
Code:screen:blit(enemy.x,enemy.y,enemy1)
end
if enemy.x > 0 then
enemy.x = enemy.x + 10
end
screen:blit(enemy.x,enemy.y,enemy1)
screen.flip()
OK, what does your array say?
Code:enemy = {}
enemy.y = 244
enemy.x = 480
Change to:Zitat:
Zitat von Gutya
If you want to add more enemies later then do this:Code:enemy={x=480, y=244}
etc...Code:enemy={}
enemy[1]={x=480, y=244}
enemy[2]={x=460, y=244}
Also, you might want to read PSPillionaire's tutorials, they are really good and they explain all about arrays and anything you need to know about LUA. www.evilmana.com is his website where the tutorials are.
Yes, i know how to do that, and i have read the tutorial, but that doesnt fix my problem at all.
Try that.Code:screen:blit(enemy.x,enemy.y,enemy1)
end
if enemy.x > 0 then
enemy.x = enemy.x - 10
end
screen:blit(enemy.x,enemy.y,enemy1)
screen.flip()
Doesnt work, do you have another soloution? All i want is for enemy1 to move from right to left.
k well i'm back and i seen 1 answer to my question but it didn't help and so you don't have to go all the way back though heres my code to help:
if you look at it it runs fine just when you go though the first 5 then it stops fireing them can someone help me please=-)Code: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 a=1,5 do
paintballs[a]={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 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)
if paintballs[i].x>480 then paintballs[i].firing=false
end
end
end
while true do
pad=Controls.read()
screen:clear(black)
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:print(10,110,currentpaintball,green)
screen.waitVblankStart()
screen.flip()
oldpad=pad
end
ok ive got my randomization problem down to the part theres an error at
the blue part is where the error is at. when i get rid of the if statment and just leaveCode: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
it does the randomization fine. but when i add it back in it never assigns them the new number.Code: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
in thery this should write "hello" to the screen right?
if menustatus == 0 then
screen:print(10, 10, "hello", green)
screen:blit(0,0,bg1)
screen.flip()
end
its part of a menu, im wondering why doesnt the text show
edit nevermind, all i had to do was flip the text and pic around