The only thing I can think of is maybe you're loading too many images OR what I think the problem is, is "lv1.png" Is "lv1.png" a huge image? If it is it might be having problems blitting it or even loading it.
Printable View
The only thing I can think of is maybe you're loading too many images OR what I think the problem is, is "lv1.png" Is "lv1.png" a huge image? If it is it might be having problems blitting it or even loading it.
Well the images are like 4kb apiece and the BG is a 480x272 image thats.... wtf... 90kb... maybe thats the problem
EDIT: And it is. Thank you! now I need a new BG :dry:
OKay... umm how do I have it so when I press left on the d-pad a left arrow will show. But when I press right a right arrow shows? (And the left arrow be gone so it doesnt look like <->)
Like this:
That should work.Code:right = Image.load("rightarrow.png")
left = Image.load("leftarrow.png")
background = Image.load("background.png")
while true do
pad = Controls.read()
if pad:right() then
screen:blit(0, 0, background)
screen:blit(10, 10, right)
end
if pad:left() then
screen:blit(0, 0, background)
screen:blit(10, 10, left)
end
end
Doesnt really work... It makes it all slow and Im doing it for a sidescrolling engine with multiple images on the screen.
I know that this is a real noob like question but:
What does the alpha channel in LUA do and how do i use it?
--Vaza
Something I've noticed when looking through a bunch of the lua homebrew. In platformers, specifically, I see folks making multiple copies of the same sprite so they have a left and right direction of each. I assume that it'd be more convenient to simply mirror the sprite horizontally when drawing, depending on the desired direction. I'd hoped to test it myself, but I've been hard pressed to find a bit of code lending this function. Looking into the lua snippets, I found something that I thought might lead me to an answer, but I've hit a bit of a road block.
The rotate by 90 degrees code,
with the included image, seems to show an image being simply rotated by 90 degrees. However, when you change the image, you see that it actually gets mirrored either horizontally or vertically while being rotated.Code:-- Variables
smile = Image.load("smiley.png")
function rotateImage(theImage)
newImage = Image.createEmpty(theImage:height(), theImage:width())
for x = 1, theImage:width() do
for y = 1, theImage:height() do
newImage:blit(y, x, theImage, x, y, 1, 1)
end
end
return newImage
end -- rotateImage
--main program
screen:blit(0, 0, smile)
screen:blit(100, 0, rotateImage(smile))
screen:flip()
screen.waitVblankStart(600)
http://img.photobucket.com/albums/v3...o/Rotation.png
I've messed with bits of it, but I'm still new to these lua functions, and find that one often has to find a workaround for non-defaults. Some help with the matter would be much appreciated.
You could use this to mirror it (just made it, so I haven't tested it, but it should work):
Pretty easy actually (yes I used this code as a basis).Code:-- Variables
smile = Image.load("smiley.png")
function mirrorImage(theImage)
newImage = Image.createEmpty(theImag e:height(), theImage:width())
for x = theImage:width(),1,-1 do
for y = 1, theImage:height() do
newImage:blit(x, y, theImage, x, y, 1, 1)
end
end
return newImage
end -- rotateImage
It sets the transparency. 0 is no transparency and 255 is full transparency.Zitat:
Zitat von Vaza
Actually, it does the exact same thing as if you had only swapped the x and y in the blit function: copied the image exactly as it had been. Thanks for the attempt, though.Zitat:
Zitat von Altair
i need help on doing that too,,Zitat:
Zitat von Paburo
Can any one help me I want my program to Save a irda signal to a variable on a botton press while selecting an object on a menu.
This is what I have so far:
Code:if pad:circle() and menustatus == -1 then
irdasignal = System.irdaRead()
end
Huh? It should work assuming that LUA starts at the last x and ends with the first one. I looked it up in the manual and LUA should be able to do that because I make it use steps of -1.Zitat:
Zitat von Paburo
Did you try it with the yellow/purple smiley?
I wouldn't try it with any other. Implimenting the code you handed me, the image is just copied exactly.Zitat:
Zitat von Altair
http://img.photobucket.com/albums/v3...co/Mirror1.pngCode:-- Variables
smile = Image.load("smiley.png")
function mirrorImage(theImage)
newImage = Image.createEmpty(theImage:height(), theImage:width())
for x = theImage:width(),1,-1 do
for y = 1, theImage:height() do
newImage:blit(x, y, theImage, x, y, 1, 1)
end
end
return newImage
end -- rotateImage
screen:blit(0, 0, smile)
screen:blit(100, 0, mirrorImage(smile))
screen:flip()
screen.waitVblankStart(600)
Got it I forgot that it uses the same x:
Code:smile= Image.load("smiley.png")
function mirrorImage(theImage)
newImage = Image.createEmpty(theImage:width(),theImage:height())
x2=0 --second x needed otherwise it pastes the x at the same place
for x = theImage:width(),0,-1 do
for y = 0, theImage:height() do
newImage:blit(x, y, theImage, x2, y, 1, 1)
end
x2=x2+1
end
return newImage
end
screen:clear()
screen:blit(0, 0, smile)
screen:blit(100, 0, mirrorImage(smile))
screen.waitVblankStart()
screen:flip()
while true do -- this is just for testing purpose
screen.waitVblankStart()
pad = Controls.read()
if pad:start() then
break
end
end
Ok.. Im making a sidescroll engine and I need help with direction association with the sprites when i press left and right. Ive tested a few things but I get over lapping images... help?
Zitat:
Zitat von MaSt3r_ShAk3
are you coding your own? or are u using my tut? OR are you using lumos code??
Which tuts are you reffering to?
Heres my codeCode:black = Color.new(0,0,0)
--VARIABLES/ARRAYS--
player = {}
player.x = 20
player.y = 200
enemy = {}
enemy.x = 420
enemy.y = 200
poox = nil --poox, pooy = player poo--
pooy = nil
poo2x = nil --poo2x, poo2y = AI poo--
poo2y = nil
at=1 --Air Time--
aj=0 --Active Jump--
r=0 --Ready (To Jump)--
z = 0
--IMAGES--
browndashleft = Image.load("brown/monkey1dashl.png")
browndashright = Image.load("brown/monkey1dashr.png")
brownhitleft = Image.load("brown/monkey1hitl.png")
brownhitright = Image.load("brown/monkey1hitr.png")
brownjumpleft = Image.load("brown/monkey1jumpl.png")
brownjumpright = Image.load("brown/monkey1jumpr.png")
brownstandleft = Image.load("brown/monkey1standl.png")
brownstandright = Image.load("brown/monkey1standr.png")
bluedashleft = Image.load("blue/monkey2dashl.png")
bluedashright = Image.load("blue/monkey2dashr.png")
bluehitleft = Image.load("blue/monkey2hitl.png")
bluejumpleft = Image.load("blue/monkey2jumpl.png")
bluejumpright = Image.load("blue/monkey2jumpr.png")
bluestandleft = Image.load("blue/monkey2standl.png")
bluestandright = Image.load("blue/monkey2standr.png")
bg = Image.load("background.png")
--FUNCTIONS--
function moveleft()
z = 1
if player.x > 0 then
player.x = player.x - 5
end
end
function moveright()
z = 2
if player.x < 456 then
player.x = player.x + 5
end
end
function textbgstuff()
screen:blit(0,0, bg, false)
screen:print(2,2, "WiP Engine Test", black)
screen:print(2,12, "DONE: Movement, Sprites, jumping", black)
screen:print(2,22, "TODO: throwing, AI, collision, directional association", black)
end
function blitstuff()
screen:blit(player.x, player.y, browndashright)
screen:blit(enemy.x, enemy.y, bluestandleft)
end
function throw()
--being worked on--
end
function jump()
--being worked on--
end
function direction()
if z == 1 then
screen:blit(player.x, player.y, browndashleft)
end
if z == 2 then
screen:blit(player.x, player.y, browndashright)
end
end
function jump()
if aj==0 and math.abs(player.y) > 199 then
r=1 else r=0
end
if pad:square() and r==1 then
aj=1
end
if aj==1 and math.abs(at) < 100 then
player.y=player.y-5
at=at+1
end
if at==20 then
aj=0
at=1
end
if aj==0 and math.abs(player.y) < 200 then
player.y=player.y+6
end
end
while true do ----MAIN LOOP----
screen:clear()
textbgstuff()
pad = Controls.read()
if pad:left() then
moveleft()
end
if pad:right() then
moveright()
end
direction()
jump()
if pad:start() then
break
end
blitstuff()
screen.flip()
screen.waitVblankStart()
end
Zitat:
Zitat von MaSt3r_ShAk3
umm, how is that a sidescrolling engine??
Well its sidescrolling... maybe im not using the right terminology... but i still need help...
is our background moving to the left or right automatically??Zitat:
Zitat von MaSt3r_ShAk3
No... okay i get it its not an engine but I still need help..........
Master Shake, is that the Monkey Poo fight game you and bronx are doing?
Yeah.
Are you gonna finish flipbook?
At one point... butterballer on psp-programming said he wanted to work with me and i accepted and he said he rewrote flipbook completely... but Im gonna wait til I get back in florida to do any more work on that
Zitat:
Zitat von MaSt3r_ShAk3
can u pm me the files wit the images?? i u want?? i can tyr to fix it. i cant see wha you mean by using words. i wont steal. i dont need to,
I got two questons
1.
Can any one help me I want my program to Save a irda signal to a variable on a botton press while selecting an object on a menu.
This is what I have so far:
2.Code:if pad:circle() and menustatus == -1 then
irdasignal = System.irdaRead()
end
when I hit left or right my pic. doesnt move but when I hit up or down it moves .
Code:red = Color.new(255, 0, 0);
white = Color.new(255, 255, 255);
char = Image.load("char.png")
y = 100
x = 100
while true do
screen:clear()
-- read current pad
pad = Controls.read()
if pad:up() then
y = y - 1
elseif pad:down() then
y = y + 1
elseif pad:left() then
X = x - 1
elseif pad:right() then
X = x + 1
end
screen:blit(x, y, char, 0, 0, char:width(), char:height(), true)
screen.flip()
screen.waitVblankStart()
if pad:start() then break end
end
Zitat:
Zitat von zmathue
i dont know aboyut the first question, but in the second one, have you defined cx?? or did you men to put just "x"?
I changed them to that to see if it was my variable that was the problem I guess I forgot to change it back to x when I posted.
^^i fixed the thred now^^
OKay I wrote this code so when you press X you throw something. But I have to hold X for it to travel across the screen. What would I put in the code?Code:if pad:cross() then
if z == 2 then
poox = poox + poospeed
elseif z == 1 then
poox = poox - poospeed
end
screen:blit(poox, pooy, poo)
if poox >= 480 then
poox = player.x
pooy = player.y + 12
elseif poox <= 0 then
poox = player.x
pooy = player.y + 12
end
end
I am having trouble using \n (newline) option with lua 0.16 and .20. here is my code...
--Readfile config file, print
--
red = Color.new(255, 0 , 0)
black= Color.new(0,0,0)
white= Color.new(255,255,255)
blue= Color.new(0,0,255)
grey= Color.new(192,192,192)
file = io.open("TODO", "r")
if file then
screen:clear(white)
screen:print(140,126,"Fil e Found")
screen.flip()
System.sleep(2000)
screen:clear(white)
for line in file:lines() do
screen:print(10,10,line .. "\n")
screen.flip()
end
end
else
screen:clear(black)
screen:print(140,100,"fil e Don`t Exist!",red)
screen.flip()
end
---------------------------------
What i want it to do is print the textfile to screen which it does but it only prints one line and goes off screen i want to use \n newline option but it doesn't seem to work for me. Instead of newline i get a wierd circle symbol. I am also using ttlde2.0 to edit and run my lua scripts if that helps.
Thanks for any help
Zitat:
Zitat von MaSt3r_ShAk3
try this:
THEN put:Code:if pad:cross() and oldpad:cross() ~= pad:cross() then
if poofire == false then
poofire = true
elseif poofire == true then
poofire = true
end
youll have to put in oldpad statements tho.Code:if poofire == true then
if z == 2 then
poox = poox + poospeed
elseif z == 1 then
poox = poox - poospeed
end
screen:blit(poox, pooy, poo)
if poox >= 480 then
poox = player.x
pooy = player.y + 12
elseif poox <= 0 then
poox = player.x
pooy = player.y + 12
end
end
i am having the same problem as mstrhelix if anyone could help
i could try, i guess.Zitat:
Zitat von Glynnder- PSPro
You cant use it to go to a next line on the screen, because it doesnt know what a return is. It works when you write to a file.
For the screen you have to have a variable for the y coordinate and add 8 to it for every new line.
BTW Grimfate why do you post that you will try, what help is that?
or to solve the throwing problem you could just use a loop like:
Code:if pad:cross() then
while true do
poox = poox + speed
if poox > 480 then
throw = false
end
else
screen:blit(poo)
end
well pplease can u help? that would help lol!
Also, i get what u mean with the variable thing...
Zitat:
Zitat von emericaska8r
that would work, but you cant have too many loops.
@ gynnder -PSPro, i need your code.
OK thanks, how do i use it in screen:blit() then?Zitat:
Zitat von Altair
--Vaza