ok so i blit the images in my main loop.
and will this image blit since it is 480 x 272? im just trying to get it to blit anything. (i cant get it to blit my other images)
http://i84.photobucket.com/albums/k3...ages52copy.png
Printable View
ok so i blit the images in my main loop.
and will this image blit since it is 480 x 272? im just trying to get it to blit anything. (i cant get it to blit my other images)
http://i84.photobucket.com/albums/k3...ages52copy.png
Yes because if they are not blitted in then if you ever do a screen:clear() its gone forever unless thats what you want.
right, after clearing and before flipping the screen.Zitat:
Zitat von %chrono trigger%
Zitat:
Zitat von %chrono trigger%
you need to put the 'while true do' before the blit: like this: ALSO, dont have two vars both named "player" even though one is capitalized, and it will work, but it gets confusing. name it like "playerPic":
Code:red = Color.new(255,0,0)
playerPic = Image.load("a.png")
Player = {}
Player[1] = {x=200,y=50}
while true do
screen:blit(Player[1].x,Player[1].y,player)
screen.waitVblankStart()
screen.flip()
end
thanks and can i use a timer to make images blit at certain intervals?
yes you can
good and can i use collision so my player can colect the items?
yes yes and yes.
last question is there a timer pause function in lua? im assuming there is but i dont know the syntax for it.
thnx for all your help everyone
Can someone help this guyZitat:
Zitat von GuitarGod1134
I have this code=
Im trying to make it when you have A has name then hit L it will print the word
but when i try it i get
:144: bad argument #2 to 'find' <string expected, got no value>
here is my code
Spoiler for Code:
how do u do multi-line comments in lua?
like thisZitat:
Zitat von Alex G
thats the only way i thinkCode:--BLAH BLAH
--BLAH BLAH
argh, that buggers up some of my app
Now im pretty sure he meansZitat:
Zitat von the undead
like in C++
/* BLA BLA
BLA
BLA BLA
*/
In lua Im pretty sure thats like
--[ or something I know its used in Snake Lua for the psp by shine just check in that shine puts it in all his luaplayer releases.
-= Double Post =-
--[[
Snake, Copyright (c) 2005 Frank Buss <[email protected]> (aka Shine)
artworks by Gundrosen
coding by Shine
background music: "Stranglehold", composed by Jeroen Tel, (C) 1995 Maniacs of Noise
]]
Thats how you do it taken from Snake PSP lua.
hmm, i never knew that.....now i knowZitat:
Zitat von GuitarGod1134
cheers, i though it was --[
hey, any one?Zitat:
Zitat von the undead
Zitat:
Zitat von GuitarGod1134
Spoiler for Edited Code:
-= Double Post =-
is string.find(whatever) definataly a function? I don't see how that would display anything.Zitat:
Zitat von the undead
is this an actual function?
i did that about 5 times in my code and it just comes up with a black screen and then resets. If there is a simpler way than using a timer to blit images a intervals someone tell meCode:if currentTime > 100 then
screen:blit(Jewel[1].x,Jewel[1].y,jewel)
ok, i thought of something else you could do... hopefully this is what you were trying to do:Zitat:
Zitat von the undead
yep, i tested it and it works!Code:--words
word = {}
numberofwords = 1
--A
word[1] = {letter = "A",definition = "A: The first letter of the english alphabet"}
--[[add the above stuff to the beggining, and the bottom in the correct spot
of your code]]
--SEARCH FOR A WORD
if pad:l() and oldpad:l() ~= pad:l() then
for a = 1, numberofwords do
if name == word[a].letter then
wordtodisplay = word[a].definition
break
else
wordtodisplay = "No match found."
end
end
while true do
screen:clear()
screen:print(50, 120, wordtodisplay, blue)
pad = Controls.read()
if pad:cross() then
break
end
screen.flip()
screen.waitVblankStart()
end
end
well i was gonna get some hardcore coding done tonight but since i cant fix whats wrong at the moment i guess ill just call it a night
Why is this unstickied?
me again eith another noob question
in collission i found the function to look like this (variables assigned):
but how do i define playerwidth and playerheight? b ecause when i run my code with this in it it says attempt to perform arithmetic on field "x" (a nil value)Code:function collisionCheck(Jewel)
if (Player.x + playerWidth > Jewel.x) and (Player.x < Jewel.x + Jewel.width) and (Player.y + playerHeight > Jewel.y) and (Player.y < Jewel.y + Jewel.height) then
Player.x = oldx
Player.y = oldy
end
end
is that because i didnt define player width and playerheight?
to do this, i am assuming that 'player' is an image.Zitat:
Zitat von %chrono trigger%
to get the width/height of an image you need to do:
Code:thewidth = player:width()
theheight = player:height()
well i found out that defining those variables wasn't the cause of the error. i think its the way im setting up my collision.
so if my image is defined as "jewel", but my table is defined as "Jewel". which do i put into the collision function the actual image name? (it would be c.png) or do i put the table name in it or the "jewel" variable?
lastly since it is in a table would i have to define all the elements like this:
Code:function collisionCheck(Jewel[1])
if (Player.x + playerWidth > Jewel[1].x) and (Player.x < Jewel[1].x + Jewel[1].width) and (Player.y + playerHeight > Jewel[1].y) and (Player.y < Jewel[1].y + Jewel[1].height) then
also, did yu define his X and Y numbers? if so ya gotta declere those too
yes i defined the x and y values i had my game working fine up until i added collision so i know its not the rest of the code
ok thanks....i build up from thatZitat:
Zitat von emericaska8r
-= Double Post =-
wait, that wont work because "a" was their just as a test, im going to have more words.....any way i could do it that way? or does it have to be specific?Zitat:
Zitat von emericaska8r
how do you code a function that tells you the FPS of your game/app? i learned about the timer functions, but i still dont know how to do this. :(
Any one?Zitat:
Zitat von the undead
anyone got any ideas?Zitat:
Zitat von %chrono trigger%
Zitat:
Zitat von %chrono trigger%
put the table. also, its a very bad habit to name two things the same thing, even if on is capitalized.
still a nil value error hmm ive put the table in 2 different ways and still nothing man im stumped. i dont want to paste the whole code unless someone can help so if you think you can help just reply and ill edit this and add my code
thnx
Code:function collisionCheck( aJewel )
if (Player.x + playerWidth > aJewel .x) and (Player.x < aJewel .x + aJewel .width) and (Player.y + playerHeight > aJewel .y) and (Player.y < aJewel .y + aJewel.height) then
-- do whatever
end
end
-- in the main loop
for i=1, table.getn(Jewel) do
collisionCheck(Jewel[i])
end
ok, from what i gave you, if you want to add more words to be able to be searched:Zitat:
Zitat von the undead
You need to the variable 'numberofwords' in your code to be how many words you have total, so change this number in your code as you add more words.
Then, where I have
add more, such as:Code:word[1] = {letter = "A",definition = "A: The first letter of the english alphabet"}
so if that helps, it would come out to be:Code:word[2] = {letter = "LUA", definition = "Lua: a script-based programming language for the PSP"}
Spoiler for this:
ok ill try that...if not i have already started one...but this is much cleaner(mine had a whole bunch of if statements.)Zitat:
Zitat von emericaska8r
hey sorry for being off topic here, but how do you change what it says under your picture when you post? because mine just says novice, and thats gay.
You need to buy premium, or get dev status