k did you mean it doesnt work on luaplayer windows
Printable View
k did you mean it doesnt work on luaplayer windows
i guess. does it work on ur psp tho?Zitat:
Zitat von mark.sparky
nope it doesnt work on my psp but my psp is fw 2.6 (coz no-one i know has fw1.5 :( )
hey is there anything wrong with this code because when i run it it just freezes but everything shows.
code:Code:white = Color.new(255,255,255)
red = Color.new(255,0,0)
menu = Image.load("images/menu.png")
menuselect = 0
while true do
screen:clear()
pad = Controls.read()
screen:blit(0,0,menu)
if pad:up() then
menuselect = menuselect - 1
end
if pad:down() then
menuselect = menuselect + 1
end
if menuselect == -1 then
menuselect = 1
end
if menuselect == 2 then
menuslect = 0
end
if menuslect == 0 then
screen:print(240,120,"Start",red)
screen:print(240,150,"Quit",white)
end
if menuselect == 1 then
screen:print(240,120,"Start",white)
screen:print(240,150,"Quit",red)
end
screen.waitVblankStart()
screen.flip()
end
I don't thikn anything is wrong, it seems like the psp ran out of memory if it froze, but that wouldn't make sense.
no i used it on lua player windows and when i ran it it just wouldnt move and let me change the color of the text (i.e. the selector)
Try this:
Code:white = Color.new(255,255,255)
red = Color.new(255,0,0)
menu = Image.load("images/menu.png")
menuselect = 0
while true do
screen:clear()
pad = Controls.read()
screen:blit(0,0,menu)
if pad:up() then
menuselect = menuselect - 1
end
if pad:down() then
menuselect = menuselect + 1
end
if menuselect < 0 then
menuselect = 1
end
if menuselect > 1 then
menuselect = 0 --you forgot an "e" here
end
if menuselect == 0 then -- here aswell
screen:print(240,120,"Start",red)
screen:print(240,150,"Quit",white)
end
if menuselect == 1 then
screen:print(240,120,"Start",white)
screen:print(240,150,"Quit",red)
end
screen.waitVblankStart()
screen.flip()
end
thnx its works (mostly) lol
http://www.sendspace.com/file/4jg6xl
Can someone take a look at my code. There is a problem with putting the animation on the screen.
Hey does anyone know how to do animation. Like when you are using a sprite sheet
someone told me to use this code to make a player controlled player pop up but not sure if i can get it too work
player{}
player.x
player = image.load("player.png")
controls.red()
If pad:right then
player.x = player.x + 5
end
if pad:left then
player.x = player.x -5
end
That isn't the entire code, he's just showing you an example. A complete code would be:
You can copy and paste this code it works. But you have to take out the spaces it puts in at line 9.Code:blue = Color.new(0,0,255)
player = Image.createEmpty(20,20) --creates a block 20 pixels by 20 pixels
player:clear(blue) -- colors the block blue
Player = {}
Player = {x = 460, y = 252} -- x and y coordinates of block
while true do
pad = Controls.read()
screen:clear()
screen:blit(Player.x,Player.y,player) --blits block to the screen
if pad:left() then
Player.x = Player.x - 2
end
if pad:right() then
Player.x = Player.x + 2
end
screen.waitVblankStart()
screen.flip()
end
Ok thanks a lot this wil really helpo me out a lot!
Double Post Merge
what about up and down/
Double Post Merge
i want a specified picture as the blue block also
Ffor up and down add this under right and left:Zitat:
Zitat von Bob Hoil
For a picture, just delete these line:Code:if pad:up() then
Player.y = Player.y - 2
end
if pad:down() then
Player.y = Player.y + 2
end
and add this lineCode:player = Image.createEmpty(20,20) --creates a block 20 pixels by 20 pixels
player:clear(blue) -- colors the block blue
Code:player = Image.load("YourImage.PNG")
now i need too now how to set boundries and add enemy's the tutorials don't explain very well
To ad boundries just put these lines in:
To add enemies you need to know some Artificial Intelligence, which I don't think you're that far yet. But if you want to know PM me and I can try to help you.Code:if Player.x > 460 then -- this number will change if your character size is larger
Player.x = 460 --or smaller than 20
end
if Player.x < 0 then
Player.x = 0
end
if Player.y > 252 then -- again this number will change
Player.y = 252
end
if Player.y < 0 then
Player.y = 0
end
BTW- Use Evilmana.com for tutorials, they're really easy.
adding enemy (that can control them selves a.k.a AI) is very difficult.
Depending on how intelligent the enimies are, it can be simple. Like I said you can PM me for help, or just post here and we'll try to help as much as possible.
yeah could be as simple as this.
that way the enemy just follows the character :pCode:if player.x < enemy.x then
enemy.x = enemy.x -5
end
if player.x > enemy.x then
enemy.x = enemy.x +5
end
That's how most games do it. Then soon as the enemy touches the character the health drops by 5. But it could be VERY complicated.
yeah... but if the AI is slower then the player then he would most likely never catch the player. So you need to incorporate a part in which the enemy predicts where the player is going so it can catch up. (btw, this is what I'm trying to learn to do, the prediction part).
http://www.sendspace.com/file/4jg6xl
Can someone PLEASE take a look at my code. There is a problem with putting the animation on the screen. I haven't been able to work on my game for several days now because I can't get the animation to work.
Maybe you want to give us the part that's giving you trouble. That way we don't have to look at the entire code.
Here is the code that is giving me trouble.
Code:-- Set Default Image
link = linkfaced
-- Get Default Image Height And Width
link:width()
link:height()
-- Get Screen Height And Width
screenwidth = 480 - link:width()
screenheight = 272 - link:width()
-- Player Info
player = {}
player.x = 220
player.y = 110
player.moving = "no"
player.facing = "down"
player.pad = "none"
-- Link Walking Down Animation Table
linkwalkingd = {}
linkwalkingd[1] = linkwalkingd1
linkwalkingd[2] = linkwalkingd2
linkwalkingd[3] = linkwalkingd3
linkwalkingd[4] = linkwalkingd4
linkwalkingd[5] = linkwalkingd5
linkwalkingd[6] = linkwalkingd6
linkwalkingd[7] = linkwalkingd7
linkwalkingd[8] = linkwalkingd8
-- Display Default Image
screen:clear()
screen:blit(player.x, player.y, link)
screen.flip()
screen:clear()
-- Set loop count
loopCount = 0
loopCounts = 0
-- Make Player Move Down
if pad:down() and player.y < screenheight then
player.y = player.y + 2
player.moving = "yes"
player.facing = "down"
player.pad = "down"
link = linkfaced
end
-- Link Walking Down Animation Loop
if player.moving == "yes" and player.facing == "down" then
if loopCount >= 0 and loopCount < 2 then link = linkwalkingd[1]
elseif loopCount >= 2 and loopCount < 4 then link = linkwalkingd[2]
elseif loopCount >= 4 and loopCount < 6 then link = linkwalkingd[3]
elseif loopCount >= 6 and loopCount < 8 then link = linkwalkingd[4]
elseif loopCount >= 8 and loopCount < 10 then link = linkwalkingd[5]
elseif loopCount >= 10 and loopCount < 12 then link = linkwalkingd[6]
elseif loopCount >= 12 and loopCount < 14 then link = linkwalkingd[7]
elseif loopCount >= 14 and loopCount < 16 then link = linkwalkingd[8] end
if loopCount + 1 >= 16 then loopCount = 0 else loopCount = loopCount + 1 end
end
i want it so that my character shoots a bullet and it hits him. I also need to now how to get a bullet that comes from my characters gun in his hand.
ok, Bob, you asking us for us to just give you code and yout putting it together,. Try going to evilmana.com and read the tuts their. Then come back and tell me if you know how to do all this ;)
i typed up the intro screen and everything but all of the tutorials don't explain very well i have tried that i could only get some of the code i typed to wrok even though it looked right by comparing.
probably because the tuts are for his game, do not copy, paste. You have to fit it to your own code. Post your code and let me see how much you have as of now.
well right now access denied is helping me so i will see how it goes first before i post my code.
i need help making my basic menu and so if you can help here is what i have: i know im missing something oh and all iget is flickering when i run it as in the thing i want white is white yet when i push up or down it flickers and doesn't exavtly go to the one under or over the one that is selected so yeah please help
Code:red = Color.new(255, 0, 0)
white = Color.new(255, 255, 255)
p1 = Image.load ("p1.png")
block = Image.load("block.png")
menu = 0
while true do
pad = Controls.read()
if pad:down() then
menu = menu + 1
end
if pad:up() then
menu = menu - 1
end
if menu < 0 then
menu = 2
end
if menu > 2 then
menu = 0
end
if menu == 0 then
screen:print(200, 60, "Start", white)
screen:print(200, 80, "Options", red)
screen:print(200, 100, "Quit", red)
screen:flip()
end
if menu == 1 then
screen:print(200, 60, "Start", red)
screen:print(200, 80, "Options", white)
screen:print(200, 100, "Quit", red)
screen:flip()
end
if menu == 2 then
screen:print(200, 60, "Start", red)
screen:print(200, 80, "Options", red)
screen:print(200, 100, "Quit", white)
screen:flip()
end
if pad:start() then
break
end
end
First of all, you don't need to add screen.flip() after every menu option. Second, you need to add this to the end.
Also add this line above your "while true do"Code:screen.waitVblankStart()
screen.flip()
and add this under the "screen.flip()"Code:oldpad = Controls.read()
and every time you have a "if pad" statement, change it to this:Code:oldpad = pad
This will make it so it doesn't cycle through the options so fast.Code:if pad:button() and oldpad:button() ~= pad:button then
blah blah blah
end
allright ill try it out
Double Post Merge
thanks a lot man that worked
Also, try these changes. The things I changed are in red.
By making these changes you are just cleaning up your code by having less lines.Code:red = Color.new(255, 0, 0)
white = Color.new(255, 255, 255)
p1 = Image.load ("p1.png")
block = Image.load("block.png")
menu = 0
while true do
screen:clear()-- you can't forget to add this to every program
pad = Controls.read()
screen:print(200,60,"Start",red)
screen:print(200,80,"Options",red)
screen:print(200,100,"Quit",red)
if pad:down() then
menu = menu + 1
end
if pad:up() then
menu = menu - 1
end
if menu < 0 then
menu = 2
end
if menu > 2 then
menu = 0
end
if menu == 0 then
screen:print(200, 60, "Start", white)
end
if menu == 1 then
screen:print(200, 80, "Options", white)
end
if menu == 2 then
screen:print(200, 100, "Quit", white)
end
if pad:start() then
break
end
end
hey thanks again oh and about the screen clear why do you need to put it cuase ive seen it used a lot like that and don't understand why you need it so if you could explain thatwouls be great and thanks again!
Because if you didn't have the screen:clear(), everything would be pasted on top of each other. Say you had a game, where a blue block moves around the screen. If you didn't have the screen:clear(), when the block moved thier would be a trail behind it. Take it out of your program and see what happens.
BTW- Screen:clear() always clears the screen black, but if you want a blue background or something, you could use this:
or you could use a picture for a background:Code:screen:clear(blue)
Code:screen:clear(Picture you want)
oh allright that makes sense thanks for the explanation and advice
No problem. :)
There doesn't appear to be anything wrong with the code you've shown (although I may be missing something). A problem is going on somewhere else, and that is with the "linkfaced" variable. But I have no idea what that variable is set to, so I can't help.Zitat:
Zitat von cwirsing
where can i find lua tuturails on using the psps wifi?
thanks in advance
the only way to use wifi with LUA right now is with netlib. There's no tut for it, but there is a very easy example with it. Ah whatever I'll write a very short tut:
what you need:
- netlib2.0
The file itself is called "netlib.lua". Put it in the same folder as your app (this isn't necessairy, you can also put it somewhere else, the path in the "dofile()" command will just change).
First the stuff that should be before your main loop (also remember to turn on the wifi with "Wlan.init()" and connect to the internet using "Wlan.useConnectionConfig (connection)", where "connection" is the number of the connection you want to use. For example: with Wlan.useConnectionConfig( 1) you would connect to your first connection):
1) In your app you have to import it by saying "dofile("netlib.lua") ".
2) After that you have to connect to the server with this "netconnect()"
3) Now before you can send and receive date, you have to create a variable on the server where you can send and receive your data to. You do this with the following command: netreg(id), where id is the name you want the variable to have.
(This command also makes sure the server sends the valua of the variable, whenever the valua of it changes)
Now comes the part that should be in the main loop itself
4) Now you have created a variable on the server you can send data to it by using "netsend(id, data, attribute)", where "id" is the name of the variable, data is the data in a string format (this means you have to turn tables and numbers and other formats into a string first) and where "attribute" is the way you want the data to be put in the variable. The attribute can either be "w" or "a". "w" means write and you will replace data, "a" means append and you will add the new data to the data that was already in the variable.
5) To receive data, you would say "netrecv()". This will receive all incoming data.
6) You don't have the value of the variable yet though. For that you need to use "netvalue(id)", where "id" is again the name of the variable. You need to put this after the "netrecv()" command.
After the main loop, you will need to delete the variable and close the connection:
7) To delete the variable on the server: netunreg(id), where "id" is the name of the variable
8) To close the connection to the server: netclose()
9) To close wifi: Wlan.term()
As an example I have put the example of yoursam (the author of this app) here:
As you can see he uses netget(id) instead of netrecv() and netvalue(id). Eventhough its possible, its way slower (so he said to me). He still uses it because he only needs to get the data once and not continues (I think?). If you want to get the data every loop its better to use netrecv() and netvalue(id).Code:--[[
netlib example
by youresam
]]
dofile("netlib.lua") -- netlib
Wlan.init()
print("Connecting to "..Wlan.getConnectionConfigs()[1].."...")
Wlan.useConnectionConfig(1)
print("Connecting to netlib server...")
netconnect() -- connect to netlib server
print("Setting up AMW for 'netlibtest' (wont do anything in this example..)")
netreg("netlibtest")
print("Sending 'helloworld' to 'netlibtest'")
netsend("netlibtest","helloworld","w") -- id:netlibtest data:helloworld mode:write
print("Getting 'netlibtest'...(Press start to quit)")
netget("netlibtest")
while true do
netrecv() --recieve all incoming data
buffer = netvalue("netlibtest") --what is the value of the id 'netlibtest'?
if buffer ~= "" then --if it exists...
print(buffer)
break
end
if Controls.read():start() then break end
end
netunreg("netlibtest") --ALWAYS unregister a variable when your done
netclose() --close the netlib connection
Wlan.term()
print("Program finished, hold start to exit.")
Hope it's clear enough (and right. If not please correct me anyone). I didn't explain the mail, sms and call functions. I just explained the basic sending and receiving.