What errors do you get?
Printable View
What errors do you get?
if you mean me Anti-QJ, then the error is at the 'target:pixel' line. (theres only one) it says arguments incorrect. what i'm trying to do is get the circle to appear once and put that circle as an image in the buffer so the psp can speed up.
if you meant GG, he hasnt posted what was his error.
EminentJohnFrost: Just put in the actual numbers for x and y, since it only draws the circle one time.
but then it wouldnt move
and its not becuase of lag
No I mean when you're drawing the circle to the player, not when you're blitting the player.
your drawing 8 circles every frame, and trig functions are ram hoggers. i would recommed having separate images and just load them.Zitat:
Zitat von EminentJonFrost
im trying to generate a random numbwe, so i put
var = math.random(0,9)
so it would generate a value btw 0 and 9, im running the script on Windows Lua player, but it always generate me the number 0. Why?
Probably because you're using wlp.
O well my game is fine Im putting it on hold anyways. But I have another question are there any tutorials on how to use the psp analog in lua?
Look at the lua snippets thread and find the section of my snippets and theres an analog one
did you put:Zitat:
Zitat von agashka
at the beginning of your code?Code:math.randomseed(os.time())
thanks emericaska8r, now it works!
Okay when I try to run this it says my blit is a bad arguement or something.. hold on...
ok here it is exactly
error: script.lua:63: bad argument #2 to 'blit' <image
expected, got table>
just started working on this today so I know i havent blited the aliens yet or done collision or gun function.
Spoiler for Code:
Is the same as saying:Code:soldierpic[1] = {Image.load("pics/soldier/soldierup.png")}
Hence the error.Code:soldierpic[1] = {}
soldierpic[1][1] = Image.load("pics/soldier/soldierup.png")
Still dont understand.
?
Zitat:
Zitat von GuitarGod1134
when you do this:
if you put {} around a table value, you must assign it a name.Code:soldierpic = {}
soldierpic[1] = {Image.load("pics/soldier/soldierup.png")}
soldierpic[2] = {Image.load("pics/soldier/soldierdown.png")}
soldierpic[3] = {Image.load("pics/soldier/soldierleft.png")}
soldierpic[4] = {Image.load("pics/soldier/soldierright.png")}
so:
then, when blitting, do this:Code:soldierpic = {}
soldierpic[1] = {pic = Image.load("pics/soldier/soldierup.png")}
soldierpic[2] = {pic = Image.load("pics/soldier/soldierdown.png")}
soldierpic[3] = {pic = Image.load("pics/soldier/soldierleft.png")}
soldierpic[4] = {pic = Image.load("pics/soldier/soldierright.png")}
Code:screen:blit(soldier[1].x,soldier[1].y,soldierpic[direction].pic)
OR: you could just do this:
remove the {}:like this:
Code:soldierpic = {}
soldierpic[1] = Image.load("pics/soldier/soldierup.png")
soldierpic[2] = Image.load("pics/soldier/soldierdown.png")
soldierpic[3] = Image.load("pics/soldier/soldierleft.png")
soldierpic[4] = Image.load("pics/soldier/soldierright.png")
and then blit it like you were trying to:
Code:screen:blit(soldier[1].x,soldier[1].y,soldierpic[direction])
Remove the brackets?
EDIT: ok I see. thanks.
EDIT2: ok works perfectly now thanks.
No you don't:Zitat:
Zitat von Grimfate126
array [1][1] will be 1Code:array = {}
array [1] = {1, 2, 3, 4, Image.load("something.png") }
array [1][2] will be 2
array [1][3] will be 3
array [1][4] will be 4
array [1][5] will be the loaded image.
Zitat:
Zitat von head_54us
yes, but i was talking about 1D arrays. :p
but thats very important too. so yeah.
1D arrays are exactly the same as well.Zitat:
Zitat von Grimfate126
array [1] will be 1Code:array = {1, 2, 3, 4, Image.load("something.png") }
array [2] will be 2
array [3] will be 3
array [4] will be 4
array [5] will be the loaded image.
This is also the same as 3D, 4D, 5D, etc arrays.
Ok new error but same error message. Only happens when I press x though so it has something to do with the bullets.
Spoiler for Code:
screen:blit(bullet[1].x,bullet[1].y,bullet)
variable bullet is a table not an image.
ok so i have this code, that im working on, but when i run it i get this error
any way here is my script....i cant figure out whats wrongCode:.lua:51: attempt to preform arithmetic on global "loop" <a nil value
Code:bg = Image.load("1.png")
PSP = Image.load("psp-very-small23.png")
mouse = Image.load("mouse.png")
--Tables
back = Image.createEmpty(480,272)
Back = {width=back:width(), height=back:height(), (bg) }
Back.x = 0
Back.y = 0
e1 = Image.createEmpty(27,11)
E1 = {width=e1:width(), height=e1:height(), (PSP) }
E1.x = 0
E1.y = 0
player = Image.createEmpty(19,19)
Player = { width=player:width(), height=player:height(), (mouse) }
Player.x = 200
Player.y = 200
--functions
function movePlayer()
pad = Controls.read()
if pad:left() then
Line.x = Line.x - 4
Player.x = Player.x - 4
end
if pad:right() then
Line.x = Line.x + 4
Player.x = Player.x + 4
end
if pad:up() then
Line.y = Line.y - 4
Player.y = Player.y - 4
end
if pad:down() then
Line.y = Line.y + 4
Player.y = Player.y + 4
end
end
function collisionCheck(object, object2)
if (object2.x + object2.width > object.x) and (object2.x < object.x + object.width) and (object2.y + object2.height > object.y) and (object2.y < object.y + object.height) then
return 1
end
end
--variables
speed = 1
start = 0
-loop
while true do
if start == 0 then
E1.x = math.random(480)
E1.y = math.random(40,272)
start = math.random(4)
end
if start == 1 then
E1.x = E1.x - speed
end
if start == 2 then
E1.x = E1.x + speed
end
if start == 3 then
E1.y = E1.y - speed
end
if start == 4 then
E1.y = E1.y + speed
end
if E1.x < 0 or
E1.x > 480 or
E1.y < 0 or
E1.y > 272 then
start = 0
end
movePlayer()
screen:blit(Back.x,Back.y,bg)
screen:blit(E1.x,E1.y,PSP)
screen:blit(Player.x,Player.y,mouse)
if collisionCheck(Player,E1) then
speed = speed + 1
start = 0
end
screen.waitVblankStart()
screen.flip()
end
This part, Your loop only has one "-", It needs to beZitat:
Zitat von the undead
--loop
haha, thank you i didnt catch that lolZitat:
Zitat von Anti-QJ
Bleh, took too long.
-loop
should be
--loop
No problem, Everyone makes simple mistakes. I do all the time.Zitat:
Zitat von the undead
-= Double Post =-
[Edit]
2 "end"s are there. ;)Zitat:
Zitat von Anti-QJ
Ah, Thanks
I havent posted in here for along time, let alone needing help ;) but since Im stuck with LUA for now (to dev something efficiently) Im in need of some assistance.
Im wanting to fade from one image to another. Im certain I can figure this out on my own, but why reinvent the wheel, thats a saying, when I could use a pre-made one. So really, Im asking how to fill an image with a color...
Is it:
image:fill(color)?
I need a LUA function reference - C has faded my LUA memories :o
Heres sometyhing i found at psp-programming.com
Draws a filled rectangle.Code:nil image:fillRect(x, y, width, height, [color = transparent-black])
Maybe some editing of this can do it.
Just for, lets say a refleks game, is there a function like:
screen.waitVblankStart(25-150)
Or what else can you do?
Gameo - that should crash as you cant delay the vsync a negative amount.
Anti-Qj - If thats the case, then image;clear(color) should work, since the first part of the statement must mean the object to draw to... screen:clear your clearing the screen, image:clear your clearing the image, it all seems to add up... Im gonna try it now.
Ok whenever I press x my bullet appears but its very far away from my soldier and it only stays blitted as long as Im holding cross. Also I need help on doing collision for my aliens because when I set them to chase the player they all group into one alien and it looks like one alien is chasing me instead of 10.
Spoiler for CODE:
What should i type then for a random timer between (something-something)??
GuitarGod - I rather not create your game - sorry. But seriously, re-read your code. If your chase the player code is the problem, look at it. Im certain your setting all 10 aliens the same X and Y values thus creating hte one alien effect. AS for collision, contrary to popular belief, its quite easy. Search these forums for a LUA bounding box collision. As for bullets, thats asked sooooooo many times its almost a stereotype, if not already, for every LUA user to ask for help on making it... Just search or look at that evilmania thing, if not already.
Anyways, im still thinking up methods of fading, but i cant seem to set an image to transparent completely, ratheri can only set an image to a completely black color and a transprency %. Know of any LUA app that fades from one image to another?
EDIT
Gameo -
RanNumber = math.random(1,100)
-- get random number between 1 and 100
So that's it?! Eaasy, i love Lua!Zitat:
Zitat von SG57
But seriously, even though almost everyone can release a refleks game with 2 images and a little code, im gonna put more work into this.
(Don't want my first release to be crappy.)
thats the way start simple and work your way up
my first game was a rock, scissors, paper simple but i got a lot out of it.
Yes, and ty.Zitat:
Zitat von mafia1ft
Lol. yah that game was just off the top of my head. Anyways My ai is fine they all follow the player like I want but I have to implement collision because when they all follow the player after a while they turn into one lol. And I saw a tut on evil that ill try for bullets but for collision its something wierd like.
if (Player.x + playerWidth > object.x) and (Player.x < object.x + object.width) and (Player.y + playerHeight > object.y) and (Player.y < object.y + object.height) then
But what is object.height and stuff. Are they variables? or are they somekind of statement? and playerwidth and hieght are variables right? In the evilmana tut he never declares object.height or width.