Advertising (This ad goes away for registered users. You can Login or Register)

[LUA] Need help with code plz

Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
feng2028
Posts: 3
Joined: Wed Oct 31, 2012 4:08 pm

Re: [LUA] Need help with code plz

Post by feng2028 »

That will stop the loop inside the function from running.
Advertising
Different55
Posts: 130
Joined: Thu Jun 07, 2012 9:28 pm

Re: [LUA] Need help with code plz

Post by Different55 »

What?

Your post needs more context.
Advertising
dragonxtamer596
Posts: 188
Joined: Wed Oct 24, 2012 11:49 pm
Contact:

Re: [LUA] Need help with code plz

Post by dragonxtamer596 »

For some reason my images aren't showing on my psp screen, why is that?
qwikrazor87
Guru
Posts: 2874
Joined: Sat Apr 21, 2012 1:23 pm
Location: The North Pole

Re: [LUA] Need help with code plz

Post by qwikrazor87 »

It is most likely an error in your code. I can't say much more since you haven't posted your code.
PSP 2001 - TA-085 - 6.61 PRO-C2
PS Vita 3G - PCH-1101 - 3.65 HENkaku Ensō
Alcatel phone - Android 8.1.0
Laptop - Toshiba Satellite L305D-S5974 - Ubuntu 16.04 LTS
dragonxtamer596
Posts: 188
Joined: Wed Oct 24, 2012 11:49 pm
Contact:

Re: [LUA] Need help with code plz

Post by dragonxtamer596 »

qwikrazor87 wrote:It is most likely an error in your code. I can't say much more since you haven't posted your code.

Code: Select all

--Created by dragonxtamer596

--On the 10/25/12


Room_width = 480 
Room_height = 272 
player1x =240
player1y =136
---Load Sprites --- 
background =Image.load ("images/Background.PNG")
player1=Image.load("images/Player1.PNG")

------functions 
function checkcontrols()
pad = Controls.read()
if pad:start() then
  break
end

if pad:right() then
player1x = player1x +2
end

if pad:left() then
player1x = player1x -2
end

if pad:up() then
player1y = player1y  -2
end

if pad:down() then
player1y = player1y +2
end
end

function drawall() 
screen:blit (0,0,background)
screen:blit(player1x,player1y,player1)
screen.waitVblankStart()
screen.flip()
end 

-- MAIN LOOP 
while true do 
checkcontrols()
drawall()
end
Same code as before
qwikrazor87
Guru
Posts: 2874
Joined: Sat Apr 21, 2012 1:23 pm
Location: The North Pole

Re: [LUA] Need help with code plz

Post by qwikrazor87 »

dragonxtamer596 wrote:--Created by dragonxtamer596

--On the 10/25/12


Room_width = 480
Room_height = 272
player1x =240
player1y =136
---Load Sprites ---
background =Image.load ("images/Background.PNG")
player1=Image.load("images/Player1.PNG")

------functions
function checkcontrols()
pad = Controls.read()
if pad:start() then
break
end

if pad:right() then
player1x = player1x +2
end

if pad:left() then
player1x = player1x -2
end

if pad:up() then
player1y = player1y -2
end

if pad:down() then
player1y = player1y +2
end
end

function drawall()
screen:blit (0,0,background)
screen:blit(player1x,player1y,player1)
screen.waitVblankStart()
screen.flip()
end

-- MAIN LOOP
while true do
checkcontrols()
drawall()
end
Try removing the spaces before "(" in the red areas.
Also check that the images do not exceed the 512 by 512.
If those aren't the problems then I don't know what's going wrong. :?
PSP 2001 - TA-085 - 6.61 PRO-C2
PS Vita 3G - PCH-1101 - 3.65 HENkaku Ensō
Alcatel phone - Android 8.1.0
Laptop - Toshiba Satellite L305D-S5974 - Ubuntu 16.04 LTS
dragonxtamer596
Posts: 188
Joined: Wed Oct 24, 2012 11:49 pm
Contact:

Re: [LUA] Need help with code plz

Post by dragonxtamer596 »

Have any links to get me headed in the right direction for making an rpg? Also is there a better, easier language out there for 2d psp with a lot of tutorials?
Different55
Posts: 130
Joined: Thu Jun 07, 2012 9:28 pm

Re: [LUA] Need help with code plz

Post by Different55 »

dragonxtamer596 wrote:Have any links to get me headed in the right direction for making an rpg? Also is there a better, easier language out there for 2d psp with a lot of tutorials?
http://www.koonsolo.com/news/make-rpg-by-yourself/
http://www.darkshire.net/jhkim/rpg/theo ... nning.html

There are better ones, not sure about easier.
dragonxtamer596
Posts: 188
Joined: Wed Oct 24, 2012 11:49 pm
Contact:

Re: [LUA] Need help with code plz

Post by dragonxtamer596 »

Different55 wrote:
dragonxtamer596 wrote:Have any links to get me headed in the right direction for making an rpg? Also is there a better, easier language out there for 2d psp with a lot of tutorials?
http://www.koonsolo.com/news/make-rpg-by-yourself/
http://www.darkshire.net/jhkim/rpg/theo ... nning.html

There are better ones, not sure about easier.
http://www.koonsolo.com/news/make-rpg-by-yourself/ ......... then what should i start with if an rpg is a bad idea.
dragonxtamer596
Posts: 188
Joined: Wed Oct 24, 2012 11:49 pm
Contact:

Re: [LUA] Need help with code plz

Post by dragonxtamer596 »

dragonxtamer596 wrote:
Different55 wrote:
dragonxtamer596 wrote:Have any links to get me headed in the right direction for making an rpg? Also is there a better, easier language out there for 2d psp with a lot of tutorials?
http://www.koonsolo.com/news/make-rpg-by-yourself/
http://www.darkshire.net/jhkim/rpg/theo ... nning.html

There are better ones, not sure about easier.
http://www.koonsolo.com/news/make-rpg-by-yourself/ ......... then what should i start with if an rpg is a bad idea.
nvm i've got it
my old code number generator

Code: Select all

-- My Second Lua Program
-- Author: Dragonxtamer596

red = Color.new(255, 0, 0) 

function checkcontrols()
pad = Controls.read()
if pad:start() and oldpad:start() ~= pad:start() then
choice = math.ceil(math.random(1, 3))
end

if choice == 1 then 
screen.print(200, 100, "1", red) 
end

if choice == 2 then 
screen.print(200, 100, "2", red) 
end

if choice == 3 then 
screen.print(200, 100, "3", red) 
end

while true do
oldpad = Controls.read()
screen:clear()
screen.flip() 
screen.waitVblankStart()
end
end
How do I make it so the random number is a function that i can put in the main loop like below because as soon as it starts it ends.

Code: Select all

grass = Image.load("grass.png")
player = Image.load("player.png")
flower = Image.load("flower.png")
 
screenwidth = 480 - player:width()
screenheight = 272 - player:width()
 
Player = { }
Player[1] = { x = 200, y = 50 }
 
-- Function to check player movements
function playerMovement()
   pad = Controls.read()
     if pad:left() and Player[1].x > 0 then
       Player[1].x = Player[1].x - 2
     end
 
   if pad:right() and Player[1].x < screenwidth then
     Player[1].x = Player[1].x + 2
   end
 
   if pad:up() and Player[1].y > 0 then
     Player[1].y = Player[1].y - 2
   end
 
   if pad:down() and Player[1].y< screenheight then
     Player[1].y = Player[1].y + 2
   end
end
 
-- Function to paste images to screen
function pasteImages()
   for a = 0, 14 do
     for b = 0,8 do
       screen:blit(32 * a, 32 * b, grass)
     end
   end
 
   screen:blit(100,100,flower)
   screen:blit(300,220,flower)
 
   screen:blit(Player[1].x,Player[1].y,player)
end
 
-- Main Loop
while true do
 
   screen:clear()
 
   pasteImages()
 
   playerMovement()
 
   screen.waitVblankStart()
   screen.flip()
end
Locked

Return to “Programming and Security”