WHy doesnt this work?
i want my enemy to walk across the screen.Code:screen:blit(enemy.x,enemy.y,enemy1)
end
if enemy.x > 1 then
enemy.x = enemy.x - 10
end
screen:blit(enemy.x,enemy.y,enemy1)
screen.flip()
Printable View
WHy doesnt this work?
i want my enemy to walk across the screen.Code:screen:blit(enemy.x,enemy.y,enemy1)
end
if enemy.x > 1 then
enemy.x = enemy.x - 10
end
screen:blit(enemy.x,enemy.y,enemy1)
screen.flip()
Cant tell you. I need to see more of your code. This part looks good, allthough i dont get why there are two "screen:blit(enemy.x,enem y .y,enemy1)", but that is probably because i dont see the rest of your code.
BTW People we're over the 1000 posts! WOOHOO!!!
Well i have this so far:
Code:--Colors
green=Color.new(0,255,0)
white=Color.new(255,255,255)
--Load Images
stand = Image.load("Images/stand.png")
jump = Image.load("Images/jump.png")
ground = Image.load("Images/ground.png")
background = Image.load("Images/background.png")
enemy1 = Image.load("Images/enemy.png")
--Variables
sprite = stand
num = 0
--Arrays
player = {}
player.gravity = 230
player.y = 230
player.x = 50
player.jumpspeed = 10
player.jumpstate = "ground"
enemy={x=480, y=244}
--Character Settings
function character()
if pad:cross() and player.jumpstate == "ground" then player.jumpstate = "jumping" end
if player.jumpstate == "jumping" then
player.jumpspeed = player.jumpspeed - 0.5
player.gravity = player.gravity - player.jumpspeed
end
if player.gravity < 0 then
player.jumpstate = "falling"
end
if player.gravity < 230 and player.jumpstate == "falling" then
player.gravity = player.gravity + (player.jumpspeed + 3)
end
if player.gravity == 230 then
player.jumpspeed = 10
player.jumpstate = "ground"
end
if player.gravity > 230 then player.gravity = 230 end
player.y = player.gravity
if player.jumpstate == "ground" then
sprite = stand
end
if player.jumpstate == "jumping" then
sprite = jump
end
screen:blit(player.x,player.y,sprite)
screen:blit(0,262,ground)
end
--Enemy 1 settings
function enemyset()
if enemy.x == 50 and player.jumpstate == "ground" then
screen:clear()
screen:print(240,136,"Game Over",green)
screen.waitVblankStart()
screen.flip()
end
screen:blit(enemy.x,enemy.y,enemy1)
end
if enemy.x > 1 then
enemy.x = enemy.x - 10
end
--Take a screenshot
function screenshot()
if pad:select() then
screen:save("screenshot.png")
end
end
--Number
function number()
if pad:select() then
num = num + 1
end
end
--Main Loop
while true do
pad = Controls.read()
screen:blit(0,0,background,false)
character()
enemyset()
screen.waitVblankStart()
screen.flip()
screenshot()
number()
if pad:start() then
break
end
end
because its not in your enemyfunction (count the functions, if's and end's). So its not called upon. Change it to something like this:
Code:function enemyset()
if enemy.x == 50 and player.jumpstate == "ground" then
screen:clear()
screen:print(240,136,"Game Over",green)
screen.waitVblankStart()
screen.flip()
end
screen:blit(enemy.x,enemy .y,enemy1)
if enemy.x > 1 then
enemy.x = enemy.x - 10
end
end
Edit: Forget it.
Ahh sorted, my game is almost ready!
great!
Ok for ones i have a question:
Im blitting everything on an image and then i blit this image onto the screen. Now the thing thats going wrong is that the image isn't getting cleared so everything blits on top of eachother. Now the question is this: how do i make it so that it doesnt blit it on top of eachother, so how do i clear the image?
I tried clearing it and then blitting the stuff back, but clearing takes a long time when its a big image, so it goes really slow.
Also i tried putting the background image over it all, but i cant get that to work. What i do is this:
But map=level doesn't seem to work.Code:map=image.load('map.jpg')
level=map
whil true do
map=level
map:blit(....)
map:blit(....)
screen:blit(0,0,map,....)
etc.
end
I feel bad that i can't help after all the help you have given me. :cry:
Dont worry about it. As long as someone can and wants to help me :P