PDA

View Full Version : help with my platform game please!



shiftybill
January 2nd, 2006, 09:35
heya all i decided to make a simple megaman game in LUA

im having trouble displaying some of the pictures heres some of my code


function input()
pad = Controls.read()
if pad:left() or pad:right() == true then
move = true
else
move = false
end
if move == true then
if pad:left() then
stance = mmrunleft
lastdir = left
end
if pad:right() then
stance = mmrunright
lastdir = right
end
end

if move == false then
if lastdir == left then
stance = mmstandleft
end
if lastdir == right then
stance = mmstandright
end
end
end

while true do

input()

screen:blit(playerx, playery, stance[picnumber], true)

end


when i let go of either the left or right button it always displays the standing right pictures, I dont know how to fix this plese help me!

cancan
January 2nd, 2006, 11:12
You should add:
screen:waitVblankStart()
screen:flip()
After the screen:blit

I think it will also be better not to blit the player directly on the screen but on an image and to blit the image on the screen later on.

something like:
board:clear()

board:blit(0, 0, background, 0, 0, background:width(), background:height(), false)
board:blit(playerx, playery, stance[picnumber], true)
screen:blit(0, 0, board)


Before the loop create the board image like this:
board = Image.createEmpty(480, 272)

and load the background image (called here background :) ) like this:
background = Image.load("background.png")

By doing this it shold avoir some flickering.

shiftybill
January 2nd, 2006, 12:14
Thanks for your advice, I will add that to my game.

Yet I still cant get the correct images to be displayed.

shiftybill
January 6th, 2006, 12:57
ok thanks for the help so far, i have all the running and jumping pictures working!

but now I need some help with collision, i have it working but when you scroll the background it scrolls the image but not the collision stuff, its hard to explain, its like the background is still in the same place, yet its moving

thx in adv. it late and im tired heres a little demo

http://www.freewebs.com/shifthouse/MegaMan.zip

.:PSP1.0:.
January 7th, 2006, 08:03
Hey man really interested in what it looks like but the link you posted only bring me back to this page.. :confused:

wraggster
January 7th, 2006, 12:20
upload to this forum, makes it easy to download ;)

shiftybill
January 7th, 2006, 14:36
if u copy then paste the link in a new window it will work

my psprecious
February 19th, 2006, 05:55
You need to set your collision map to the coordinates of your scroll, I'm not sure this is your problem cause your code is a bit hard to read especially for a newby like me, if you woul put tiles to your code parts with -- it would be easier to elp you.