Start a timer then blit the image and text according to the timer. I could write some code but its your game/app so Im sure you want to. lol (too lazy)
Printable View
Start a timer then blit the image and text according to the timer. I could write some code but its your game/app so Im sure you want to. lol (too lazy)
hmmm i there a tut for that?
i dunno about the blit thing..:(
i know how to use the timer
thx
Image.blit(target,x,y,ima ge)
Hi
can anybody help me with this coding, if X pressed image upload.
I have tryed this but doesn't work.
code:
if pad:cross () then
image.load("image.png")
_________________________ _
But that doesn't work :(
you don't need a timer.
just do:
the 60 there can be changed to any number to wait longer or shorterCode:screen:clear()
screen:blit(0,0,backgroundimage)
screen.watiVblankStart(60)
-= Double Post =-
two things. first you need to assign that image to a variable. Also, the 'i' in image.load needs to be uppercase. heres what you should have:Zitat:
Zitat von playstationpod
Code:variablename = Image.load("image.png")
thx but...Zitat:
Zitat von emericaska8r
hmm how do i load the image?
srry
bla = Image.load("image.extensi on")
screen:clear()
screen:blit(0,0,backgroundimage) <-----ill leave this alone? or should i put the filename?
screen.watiVblankStart(60 )
-= Double Post =-
hmm it wont load load:(
Guys remember that lua uses variables and OOP.
hmmm i feel out of place lol...
-= Double Post =-
This is my code:
I get errorsCode:screen:clear()
screen.watiVblankStart(180)
backgroundimage = Image.load("credits.png")
screen:blit(0,0, backgroundimage)
screen.watiVblankStart(18 0)
needs to be
screen.waitVblankStart(180)
WOAH i cant believe i didnt see that! lol thx ill try it again
i really nid to use my glasses...:tup:
-= Double Post =-
hmm i dont get errors but the credits picture wont show
please leave a message i need to sleep now:) its 5:00AM here...:PC: need to sleep
thx
I've tried many times to make shake die and all have failed http://forums.evilmana.com/Smileys/set7/016.gifwell here's what I tried, did something wrong http://forums.evilmana.com/Smileys/set7/032.gif
Code:--///////////////// Aquateen Created By : pspfreak101, Thanks To Evilmana Tutorials\\\\\\\\\\\\\\\\\\
--///////////////// Special Thanks : Jason215, Evilmana Forums
splash = Image.load("splashScreen.png")
--OPENING SPLASH SCREEN
screen:clear()
screen:blit(0,0,splash)
screen.flip()
screen.waitVblankStart(200)
green = Color.new(0,255,0)
white = Color.new(255,255,255)
red = Color.new(255,0,0)
black = Color.new(0,0,0)
--// Player, Enemy, Ground , bullet
backgroundCache = Image.load("image.png")
backgroundCache2 = Image.load("image2.png")
backgroundCache3 = Image.load("image3.png")
backgroundCache4 = Image.load("image4.png")
light = Sound.load("light.wav", false)
light:play()
gunshot = Sound.load("gunshot.wav"), false
bullet = Image.createEmpty(4,4)
bullet:clear(green)
player1 = Image.load("figure.png")
Player = {}
Player[1] ={ x = 50, y = 200, gravity = 200, jumpspeed = 10, jumpstate= "ground"}
enemy1 = Image.load("shake.png") --// enemy image
Enemy= {}
Enemy[1] ={x = 300, y = 150, health=100, gravity = 200, jumpspeed = 10, jumpstate= "ground"}
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
Back1 = {} --------first scrolling background ( standard image 480 x 272)
Back1.x = 0 ----positioned at the start
Back1.y = 0
Back1.img = backgroundCache --- first background
Back2 = {} --------Second scrolling background ( standard image 480 x 272)
Back2.x = 480 ---- positioned precisely after the first background
Back2.y = 0
Back2.img = backgroundCache2 --- second background to scroll after first
Back3 = {} --------Third scrolling background ( standard image 480 x 272)
Back3.x = 960 ---- positioned precisely after the second background
Back3.y = 0
Back3.img = backgroundCache3 --- second background to scroll after second
Back4 = {}
Back4.x = 1440
Back4.y = 0
Back4.img = backgroundCache4
ground = Image.load("ground.png")
frame1 = Image.load("frame1.png")
frame2 = Image.load("frame2.png")
frame3 = Image.load("frame3.png")
currentFrame = 1 --this represents which frame is displaying
counter = 0 --this is the frame counter which is used to determine when to change frames
--// Variable
oldpad = Controls.read()
currentBullet = 0
direction = "right"
--// Functions
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
screen:blit(BulletInfo[i].x,BulletInfo[i].y,BulletInfo[i].pic)
end
if (BulletInfo[i].x+bullet>Enemy[1].x)and(BulletInfo[i].x<Enemy[1].x)and(BulletInfo[i].y>Enemy[1].y)and
(BulletInfo[i].y<Enemy[1].y) then
Enemy[1].health=Enemy[1].health-10
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
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
BulletInfo[currentBullet].direction = direction
BulletInfo[currentBullet].firing = true
end
function movePlayer()
if pad:left() then
Back1.x = Back1.x + 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going
Back2.x = Back2.x + 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going
Back3.x = Back3.x + 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going
Back4.x = Back4.x + 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going
direction = "left"
if Player[1].x >= 70 then -------!!!only if x is more than or = to 70 do you want to move, so you don't go offscreen. Change 70 to 150 or 0 and see what happens!!!
Player[1].x = Player[1].x - 1.5
end -------- !!!END the if pad left part
end -------- !!! now END the if x >= 70 part, so it'll only check player[1].x if pad is left, too !!!
if pad:right() then
Back1.x = Back1.x - 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going
Back2.x = Back2.x - 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going
Back3.x = Back3.x - 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going
Back4.x = Back4.x - 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going
direction = "right"
if Player[1].x <= 300 then -------!!!only if x is less than or = to 300 do you want to move, so you don't go offscreen. Change 300 to 450 or 100 and see what happens!!!
Player[1].x = Player[1].x + 1.5
end -------- !!!END the if pad left part
end -------- !!! now END the if x <= 300 part, so it'll only check player[1].x if pad is right, too !!!
if pad:up() then
Player[1].y = Player[1].y - 1.5
direction = "up"
end
if pad:down() then
Player[1].y = Player[1].y + 1.5
direction = "down"
end
end
function chasePlayer()
stallchase = math.random(2)
if stallchase == 1 then
if Enemy[1].x > Player[1].x then
Enemy[1].x = Enemy[1].x - 1
elseif Enemy[1].x < Player[1].x then
Enemy[1].x = Enemy[1].x + 1
end
end
end
function Jump() --// Function to jump
if pad:cross() and Player[1].jumpstate == "ground" then Player[1].jumpstate = "jumping"
end
if Player[1].jumpstate == "jumping" then
Player[1].jumpspeed = Player[1].jumpspeed - 0.5
Player[1].gravity = Player[1].gravity - Player[1].jumpspeed
end
if Player[1].gravity < 0 then
Player[1].jumpstate = "falling"
end
if Player[1].gravity < 200 and Player[1].jumpstate == "falling" then
Player[1].gravity = Player[1].gravity + (Player[1].jumpspeed + 3)
end
if Player[1].gravity == 200 then
Player[1].jumpspeed = 10
Player[1].jumpstate = "ground"
end
if Player[1].gravity > 200 then Player[1].gravity = 200
end
Player[1].y = Player[1].gravity
end
while true do
pad = Controls.read()
screen:clear()
counter = counter + 1
screen:clear()
if counter > 60 then --if 60 frames have passed
if currentFrame == 3 then --if we are on the last frame
currentFrame = 1 --go back to first frame (loops animation)
else
currentFrame = currentFrame + 1 --else goto the next frame
end
counter = 0 --reset the counter
end
if pad:circle() and oldpad:circle() ~= pad:circle() then
bulletSetup()
gunshot:play()
end
--// Loads Functions
movePlayer()
chasePlayer()
Jump()
--
--// blitting Image to screen and text !!!first is the bottom layer, last is the top layer!!!
if Back1.x <= 480 and Back1.x >= -480 then ----!!!if it should be visible, blit it, otherwise you're blitting stuff offscreen and slowing down the game!!!
screen:blit(Back1.x, Back1.y, Back1.img) --- blits first background to the screen
end
if Back2.x <= 480 and Back2.x >= -480 then ----!!!if it should be visible, blit it, otherwise you're blitting stuff offscreen and slowing down the game!!!
screen:blit(Back2.x, Back2.y, Back2.img) --- blits second background to the screen
end
if Back3.x <= 480 and Back3.x >= -480 then ----!!!if it should be visible, blit it, otherwise you're blitting stuff offscreen and slowing down the game!!!
screen:blit(Back3.x, Back3.y, Back3.img) --- blits third background to the screen
end
if Back4.x <= 480 and Back4.x >= -480 then
screen:blit(Back4.x, Back4.y, Back4.img)
end
bulletFire() ----!!!Blits bullets after background, but before player,enemy,text and ground-switch it up however you like !!!
screen:blit(Player[1].x, Player[1].y, player1)
screen:blit(Enemy[1].x, Enemy[1].y, enemy1)
screen:blit(0,262,ground)
if currentFrame == 1 then --draw first frame
screen:blit(Back4.x - -50,50,frame1)
screen:blit(Back4.x - -300,50,frame2)
elseif currentFrame == 2 then --draw second frame
screen:blit(Back4.x - -50,50,frame2)
screen:blit(Back4.x - -300,50,frame3)
elseif currentFrame == 3 then --draw third frame
screen:blit(Back4.x - -50,50,frame3)
screen:blit(Back4.x - -300,50,frame1)
end
screen:print(10,10,"X: "..Player[1].x.." Y: "..Player[1].y,green)
screen:print(10,20,"Jumpstate: "..Player[1].jumpstate,green)
screen:print(400,10,"You Suck",green)
screen:print(200,200,"you killed shake", red)
screen.waitVblankStart(200)
dofile("script.lua")
--
screen.waitVblankStart()
screen.flip()
end
You need to screen.flip() then do the waitVblankStartZitat:
Zitat von ai3gtmc
ok, in my program i have lots of loops for just about everything.
My loops start and end at different values, and loop different numbers of times. Is there any way to combine all of these into one loop, or minimize my loops in some way that anyone knows of?
Well, it depends on what the program looks like. Although the loops use different values, is the code inside the loops the same?
YAY it works now:)!!!
but i still have a question...whats the code that copy the whole directory
e.g. ms0:\psp\game\LuaPlayer <----COPY
ms0:\psp\game150\LuaPlaye r <----PASTE
thx:)
what kind of loops? for loops? while loops? we need to see code before reaching a conclusion. although usually, for loops arent combined unless two of them do the exact same thing. then they are usually made into a function.Zitat:
Zitat von emericaska8r
maybe he can do DOFILE ?
that also depends. its useless to dofile if you just have a bunch of for loops.Zitat:
Zitat von ai3gtmc
whats the code that copy the whole directory
e.g. ms0:\psp\game\LuaPlayer <----COPY
ms0:\psp\game150\LuaPlaye r <----PASTE
thx:)
i think there isnt code for copying WHOLE directory
Can lua create a file (not a directory)?
i think this will help many of the lua developers, especially beginners:
http://www.lua.org/manual/5.1/
A quick search on google, and voila! A lua reference manual.
EDIT: Also found another resource:
http://www.lua.org/pil/
Its an online book on lua programming.
Hope these help you guys.
I know how to create a text file in c not in lua.
well can you show me that...
i could show you but i dont think it would work in lua.
1.It's not psp specific.
ill post it if you want it though
to the people who were wondering if there was an easy way to get a file's size, here you go:
Zitat:
Zitat von Programming in Lua, 1st Edition
Yeah, just post it, i know it wont work in lua and hopefully it works with the psp.Zitat:
Zitat von eldiablov
kk one momento
-= Double Post =-
#include <stdio.h>
int main()
{
FILE *file_ptr;
file_ptr = fopen("data.txt", "w");
if(file_ptr !=NULL)
{
printf("file created\n");
fclose(file_ptr);
return 0;
}
else
{
printf("File creation failed\n");
return 1;
}
That code "should work" but im learning C so it is not certain
Same idea as CZitat:
Zitat von pspfreak9
io.open("newfile.txt","w" )
It would if they would look at it. Unfortunately, it's easier to ask somebody. To be fair, though, the question I just answered isn't really apparent from reading either of those resources.Zitat:
Zitat von parm289
I was just including those sites as general help, because most people don't wanna take the time to search for what they need. The post was not specific to your question - I was actually searching for a more efficient way to get a file's size when i came across those resources, and decided to post them here.Zitat:
Zitat von LMelior
Here, I moded youersams code to make a four player internet game. Can someone please check if everything is alright. As in logical stuff and netlib(I dont really know to much on how it works). I want to do this before I ask someone to test it with me. here is my source: (yes i know it is in a txt format)
SOURCE
I cant check it, but I highly doubt itll work. Just based on the fact that hardly anyone knows how to use netlib and that modding my 2 player script to be 4 player is near impossible.Zitat:
Zitat von pspfreak9
^ Why can't you check it? Anyways if you cant i'll just test it.
youresam i expect compensation for the inconvenience you caused me :)
Anyone wanna help me test BlackShark isnt online right now :(
i cant sorry man :(
Thats ok, maybe someone else, well can you check my code please. I dont see anything wrong with it though.
sure i'll help you [email protected]Zitat:
Zitat von pspfreak9