oh, i thought it was only inside parantheses () that spaces didnt matter.Zitat:
@ EminentJonFrost, you DO NOT need spaces between your ='s, <'s, or >',s. although they do make your code easier to read.
Printable View
oh, i thought it was only inside parantheses () that spaces didnt matter.Zitat:
@ EminentJonFrost, you DO NOT need spaces between your ='s, <'s, or >',s. although they do make your code easier to read.
I have absolutley no clue on how to do this.. but how do you make a scrolling background..
Well, your problem is that the screenblit function does not return an integer/anything bresides the image to tell if its true or not after blitting. Therefore, we must make it return something. If i am not mistakin,, you want to display an image while R and the image color at the co-ordinates 3,0 are all true. well,i do not know if this is orrect, but does the luaplayer currently have the screen:blit function return anything? besides the image? But i dunno, So if the screen:blit function/prototype does return an integer, then u can do, if screen:blit(blahcX, blahY, blah)==1 then ... That is a guess, casue usually functions/prototypes return 1 for completion/a pointer to the newly created obect/memory allocated, or return NULL for an error.Zitat:
Zitat von natan333
@montorb - A sidescrolling backround is nothng short of a simple backround, blitted usingthe co-ordsinates of a variabel you can change. Yet another mini-tut by SG57 lol:
Just a basic sidescrolling backround. There is a way to do this via either Lumo's tut, or using the offsets of the image to keep verlapping after off the screeen, but thats a little too advanced for new comers to understand :p So ya, all this is doing is blitting the backround 2 times, making there X Co-ordinates move via bgX and bg2X, and once bgX is almost offscreen, itll reset back to the start/right of the screen and keep going. Also, in C, you can declare your image's dimensions, and if the dimensions are too big, they just blit the image again until it fills those dimensions, so in C i use only have to blit my image once, use only 1 variable to change/move, etc.Code:SsBg = Image.load("side
_scrolling_bg.png")
bgX = 0
bgY = 0
bg2X = 479
ScrollingSpeed = 5
while true do
screen:blit(bgX, bgY, SsBg)
screen:blit(bg2X, bgY, SsBg)
bgX=bgX+ScrollingSpeed
bg2X=bg2X+ScrollingSpeed
if bgX<-475 then
bgX=0
bg2X=479
end
end
Hope this gives someone a basic un derstanding.
Yes it's me again! I have had another problem. This time, I'm trying to code a game/useful tool to release, and I am having a problems. One, how would you print the result from a function? Like:
function duh()
[some code]
end
screen:print(x, y, "duh: " .. duh(), color)
would that be it? Also, I am getting the error: script.lua:11: '=' expected near *
that line of code is:
function caf()
r*r*3.14 < line #11
end
then later I want to:
screen:print(x, y, "caf: " .. caf(), color)
Is that the right way?
If you get the kind of useful tool that I am trying to make, please don't steal it or post it.
And no, I tryed it spacing the *'s out, but it still doesn't work.
Thanks in advance!
you have to sayZitat:
Zitat von PSPduh
something = r*r*3.14 -- the mathematical sentence equals 'something'
i cant really tell what your app is by what your showing. but i think its a *a***l*t*r. (lol)
LOL. Sort of, but not really. How would I print that result out?
function caf()
x = r*r*3.14
end
then later...
screen:print(x, y, "caf: " .. x, color)
If i do that then it gives me an error of: attempt to concatenate global 'x' (a nil value) On line 48. That screen:print line is line 48.
And also, how do I make something happen when a button is held down for a certain amount of time?
Thanks again! (Once I release this, should be in a couple of days, I'll mention you, PSPmillionare, and whitehawk in the credits!)
Zitat:
Zitat von PSPduh
:D thanks! (for the credit)Code:screen:print(#, #, x, color) -- no parantheses, just 'x'
Ughhh, another problem...I got everything to load, the background and the r = 0 part, so now the screen is green and R = 0 appears, but when I press up, down, left, or right, it still stays the same:
This is the whole code:
Now you are probably guessing what it is, but I'll never say until its done. :icon_razzCode:red = Color.new(255,0,0)
yellow = Color.new(255, 255, 0)
blue = Color.new(0, 0, 255)
orange = Color.new(223, 88, 6)
grey = Color.new(94, 97, 111)
black = Color.new(0, 0, 0)
white = Color.new(255, 255, 255)
green = Color.new(0,255,0)
r = 0
function caf()
x = r*r*3.14
end
while true do
screen:clear(green)
pad = Controls.read()
oldpad = Controls.read()
if pad:up() and oldpad:up() ~= pad:up() then
r = r + 1
end
if pad:down() and oldpad:down() ~= pad:down() then
r = r + 5
end
if pad:right() and oldpad:right() ~= pad:right() then
r = r + 20
end
if pad:left() and oldpad:left() ~= pad:left() then
r = r + 10
end
if r > 500 then
r = 0
end
if pad:cross() then
caf()
screen:print(50, 10, 'x', black)
end
screen:print(10,10,"R = " .. r, black)
oldpad = pad
screen.waitVblankStart()
screen.flip()
end
Thanks a bunch again!
Try taking out the part that I put in bold letters.Zitat:
Zitat von PSPduh
edit - oh, and you dont need these marks: ' '
Now that I did, it works, but it goes up WAY to fast. That was the point of that oldpad. But now that its out, it works...Anyway to make it go slower without the oldpad, or a way to work it with the oldpad? Because besides that, my app does not have any other problems. Once that's worked out, then all I have to do is some more coding.
It just printed x without the ' ' marks. That line works now; it is:
screen:print(100, 100, 'caf = ' .. x, black)
Thanks.