Hm, okay after changing filenams around and bliting a white background it loads but no spike...
Printable View
Hm, okay after changing filenams around and bliting a white background it loads but no spike...
hmm. Post your code plz.
try this:Zitat:
Zitat von mark.sparky
-- Green Color Object
green = Color.new(0, 255, 0)
-- Store birth year in varible myBirthYear
myBirthYear = 1986
-- Store current year in currentYear
currentYear = 2006
-- create an empty varible
myAge = nil
-- Store some text in a varible
someText = "My age is roughly "
-- Subtract myBirthYear from cureentYear and store inmyAge
myAge = currentYear - my BirthYear
-- Print my text varible to the screen
-- Buffer offscreen to onscreen
screen.flip()
--Loop forever
while true do
screen:print(10, 100, someText .. myAge,green)
screen.waitVblankStart()
screen:flip()
end
K. All I changed was the "pic" text and added a white background. (if ur talking about the code to the game I dont have it because im totally rewriting the code)Code:spike = Image.load("spike.png")
background = Image.load("background.png")
spikex = 400
spikey = 0
while true do
screen:blit(0,0, background, false)
screen:blit(spikex, spikey, spike, 0, 0, spike:width(), spike:height())
if spikey + spike:height() < 260 then
spikey = spikey-10
end
if spikey + spike:height() > 260 then
spikey = 260 - spike:height()
end
if spikey + spike:height() == 260 then
spikex = spikex-5
end
screen.flip()
screen.waitVblankStart()
end
Whats the problem/error you get?Zitat:
Zitat von MaSt3r_ShAk3
and maybe i can help yas :icon_bigg .
Okay, im attempting to make my first ever lua game. Ive been doing lua for roughly three days and ive grasped most of it. I wanted to do a shooter and gutya(great guy) has been aiding me. Fair enough, its an in depth first project, but i wanted to try.
So i used evil manas snippets and attempted to merge them together, to get a moving shooting character.
But at the moment ive fixed a few errors but then This comes up
" Error: index.lua:29: attempt to index field '?' <a nil value>
Id appreciate someone helping me out with this code, as i dont understand parts of it myself. After this error im sure there will be more.
Code:--Activiate usb
System.usbDiskModeActivate()
--generating colours
red = Color.new(255,0,0)
black = Color.new(0,0,0)
green=Color.new(0,255,0)
white = Color.new(255,255,255)
--Create shapes
player1 = Image.createEmpty(32,32)
player1:clear(red)
ground = Image.createEmpty(480,10)
ground:clear(green)
bullet = Image.createEmpty(4,4)
bullet:clear(green)
--variables
oldpad = Controls.read()
currentBullet = 0
direction = "right"
--Arrays
player = {}
player.gravity = 230
player.y = 230
player.x = 50
player.jumpspeed = 10
player.jumpstate = "ground"
--bullet array
BulletInfo = {}
for a = 1,5 do
BulletInfo[a] = { pic = bullet , firing = false, direction = "right", x = player[1].x + 32,
y = player[1].y + 16 }
end
--Functions
function bulletSetup()
--Increase the current bullet by one, or reset it to 1
if currentBullet < 5 then
currentBullet = currentBullet + 1
else
currentBullet = 1
end
if direction == "left" then
BulletInfo[currentBullet].x = Player[1].x
BulletInfo[currentBullet].y = Player[1].y + 16
end
if direction == "right" then
BulletInfo[currentBullet].x = Player[1].x + 32
BulletInfo[currentBullet].y = Player[1].y + 16
end
if direction == "up" then
BulletInfo[currentBullet].x = Player[1].x + 16
BulletInfo[currentBullet].y = Player[1].y
end
if direction == "down" then
BulletInfo[currentBullet].x = Player[1].x + 16
BulletInfo[currentBullet].y = Player[1].y + 32
end
BulletInfo[currentBullet].direction = direction
BulletInfo[currentBullet].firing = true
end
function bulletFire()
for i = 1,5 do
if BulletInfo[i].firing == true then
if BulletInfo[i].direction == "right" then BulletInfo[i].x = BulletInfo[i].x + 10 end
if BulletInfo[i].direction == "left" then BulletInfo[i].x = BulletInfo[i].x - 10 end
if BulletInfo[i].direction == "up" then BulletInfo[i].y = BulletInfo[i].y - 10 end
if BulletInfo[i].direction == "down" then BulletInfo[i].y = BulletInfo[i].y + 10 end
screen:blit(BulletInfo[i].x,BulletInfo[i].y,BulletInfo[i].pic)
end
if BulletInfo[i].x < 0 or BulletInfo[i].x > 480 or BulletInfo[i].y < 0 or BulletInfo[i].y > 272 then BulletInfo[i].firing = false end
end
end
--Print bullet info to screen.
screen:print(10,10,"Bullet 1: ".. tostring(BulletInfo[1].firing),green)
screen:print(10,20,"Bullet 2: "..tostring(BulletInfo[2].firing),green)
screen:print(10,30,"Bullet 3: "..tostring(BulletInfo[3].firing),green)
screen:print(10,40,"Bullet 4: "..tostring(BulletInfo[4].firing),green)
screen:print(10,50,"Bullet 5: "..tostring(BulletInfo[5].firing),green)
screen:print(10,60,"Direction: "..direction,green)
--mainloop
while true do
pad = Controls.read()
screen:clear()
if pad:start() then
break
end
if pad:left() then
player.x = player.x - 2
end
if pad:right() then
player.x = player.x + 2
end
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
screen:blit(player.x,player.y,player1)
screen:blit(0,262,ground)
screen:print(10,10,"X: "..player.x.." Y: "..player.y,green)
screen:print(10,20,"Jumpstate: "..player.jumpstate,green)
screen.waitVblankStart()
screen.flip()
end
if pad:cross() and oldpad:cross() ~= pad:cross() then
bulletSetup()
end
bulletFire()
screen.waitVblankStart()
screen.flip()
oldpad = pad
Thats just some test code to make an image fall down th screen. when i test. only the background is blitedZitat:
Zitat von c5cha7
Hey, i hate to sound like a total n00b but how would i get lua player running on the gta eloader, for some reason it wont work (v0.14) - thx. :Argh: :o
anyone?Zitat:
Zitat von Greenskull
I cant figure out how to loop an animation. help please!