Code:
Thx a lot :)
Printable View
Code:
Thx a lot :)
i got bored so made a list of stuff you'd need to make it.
its not complete though.
.wav
chomping noise
splatting noise
Boom noise
whacking noise
squeaking noise
heavy object falling noise
gun shooting noise
.png
mouse looking 8 directions
mouse splatting against screen facing you
mouse splatted on ground with blood
nuclear bomb
cheese
squashed mouse
100 ton weight
shotgun
5 different backgrounds
bat
bat swinging
crosshairs
ashes of mouse
explosion
map border per bg
whoa very nice function, i could never figure out gu. i have a question though, won't this is only accept certain sizes?Zitat:
Zitat von Merick
take a look at the code for the function:
"temp" is the model table used by the Gu, and the x_start, y_start, x_end, y_end variables in the table represent the 4 corners of the image you are using, and which corner goes into which variable is determined by the "flip" argument. If you were to use standard u,v coords for these (I.E., numbers between 0 and 1) then you would get messed up graphics if you were using an image with some odd size, however here I'm using the actual image width and height which should let you use any size image without problem.Code:function Gu.blit(x, y, image, scale, flip)
if not scale or type(scale) == "string" then
flip = scale
scale = 1
end
if flip then
if flip == "H" then
x_start = image:width()
y_start = 0
x_end = 0
y_end = image:height()
elseif flip == "V" then
x_start = 0
y_start = image:height()
x_end = image:width()
y_end = 0
elseif flip == "HV" then
x_start = image:width()
y_start = image:height()
x_end = 0
y_end = 0
end
else
x_start = 0
y_start = 0
x_end = image:width()
y_end = image:height()
end
width = (image:width()*scale)+x
height = (image:height()*scale)+y
temp = {
{x_start, y_start, x, y, 0},
{x_end, y_end, width, height, 0}
}
Gu.enable(Gu.TEXTURE_2D)
Gu.texImage(image)
Gum.drawArray(Gu.SPRITES, Gu.TEXTURE_32BITF+Gu.VERTEX_32BITF+Gu.TRANSFORM_2D, temp)
end
Also in the "temp" table there are two variables, "width" and "height" which are calculated by this formula:
width = (image:width()*scale)+x
height = (image:height()*scale)+y
This changes the size that the image is drawn at by multiplying the image height and width by the scale argument, so if you have a 50x100 image and use 1.5 for the scale, then the image will be drawn at 75x150, or with a scale of 0.2 it will be drawn at 10x20.
Basically, what I'm saying is that with this there's no limits on the size of the images you can use (as long as it's at a size that lua player can normally load of coarse), or the size that you can draw them at.
wow, nice work!
edit:
oh wait one more question, the x and y coordinates are in real pixels right? so if i wanted it to be flush in the top left i would have to use -240,136 correct? and is there anyway to put this back into an image var, say blit from the screen to an image?
With the Gu, the function Gum.translate changes the coordinate system from 2d to 3d, but because Gu.blit doesn't call Gum.translate it uses the same 2d coordinate system as the regular blit.
So, to put an image at the top left, use 0,0.
As for putting it into an image, for some reason using img:blit(0,0, screen) does not capture anything that was drawn with the Gu.
However, although I haven't tried it, I believe that if you use screen:save("screen.png") to save a screenshot to an image file, then you can load that image and use it like you would any other
And actually, this isn't entirely my own code. The core of this was based on something Cools posted on the evilmana board, I just figured out how to use it with odd-sized image dimensions and added in the options for flipping the images.
yes That makes sense but I can't finish the pong tutorial because The ball doesn't move, and I havn't worked on it for days, so you want to just make a LUA PROGRAMMING TEAM for us 2 and start on RODM?Zitat:
Zitat von mraellis
Hey were are u two getting ur lua tutorials? I think ima start learning lua too :) Well i already started before.. just stopped cus there was only 2 tutorials on psp-programming
Check out Evilmana
evilmana.com thats where we're learning.
gam3freq continued into pm.
-= Double Post =-
just a update to you guys we've teamed up and started on the project and we're gonna be silent now for a bit :)
Big problem. It won't work. here is post of source:
and here is post of error:Code:-- ******* RODM: Run or Die Mouse ********
-- This was Made by Mraellis And GamefreQ for your learning purposes. Please do not steal our work, but
-- give us credit instead, and ask for our permission to use this.
dofile(Color.lua) --This directs to the color file for the colors of the text
-- Images
Bat = Image.load("Images/bat.png")
grass = Image.load("Images/grass.png")
Mouse7 = Image.load("Images/Mouse_UL.png")
Mouse9 = Image.load("Images/Mouse_UR.png")
Mouse8 = Image.load("Images/Mouse_U.png")
Mouse2 = Image.load("Images/Mouse_D.png")
Mouse4 = Image.load("Images/Mouse_L.png")
Mouse6 = Image.load("Images/Mouse_R.png")
Mouse1 = Image.load("Images/Mouse_DL.png")
Mouse3 = Image.load("Images/Mouse_DR.png")
screenwidth = 480 - player:width() -- These are so you cannot move your character off the screen
screenheight = 272 - player:width() -- because the PSP screen has 480 x 272 pixels :)
-- Tables (enemies and Players are here)
Player = { } Player[1] = { x = 200, y = 50 }
-- Sounds
Bat = Sound.load("Sounds/Bat.wav",false)
Mouse = Sound.load("Sounds/Mouse.wav",false)
Boom = Sound.load("Sounds/Boom.wav",false)
Chomp = Sound.load("Sounds/Chomp.wav",false)
heavyweight = Sound.load("Sounds/heavyweight.wav",false)
Shotgun = Sound.load("Sounds/Shotgun.wav",false)
Squash = Sound.load("Sounds/Squash.wav",false)
Levelstart = Sound.load("Sounds/Levelstart.wav",flase)
-- Vars
Win = screen:print(200, 100, "Well Done, You Won!", red)
Lose = screen:print(200, 100, "Sorry, You Lost!", blue)
Score = screen:print(200, 100, "Your score is", red)
MadeBy = screen:print(200, 100, "This Game was made by Mraellis And GamefreQ", blue)
-- Main loop
while true do
pad = Controls.read()
screen:clear()
for a = 0, 14 do
for b = 0,8 do
screen:blit(32 * a, 32 * b, grass)
end
end
screen:blit(Player[1].x,Player[1].y,Mouse8)
if pad:left() and Player[1].x > 0 then
Player[1].x = Player[1].x - 5
end
if pad:right() and Player[1].x < screenwidth then
Player[1].x = Player[1].x + 5
end
if pad:up() and Player[1].y > 0 then
Player[1].y = Player[1].y - 5
end
if pad:down() and Player[1].y < screenheight then
Player[1].y = Player[1].y + 5
end
screen.waitVblankStart()
screen.flip()
end
I don't understand. I have all of the files in the correct place (It is not done yet, no where near completion, but I just wanted to test it. but apparently not :(Code:Error: SCRIPT.LUA:19: attempt to index global 'player' (a nil value)
Press start to restart
Aiight i think i might start coding lua then...if so il hafta save up for a laptop to code on lol
I was about 2g2 bed when I say that my thread was bumped up so I got a gleam of hope only to find this LOL no problemo though it's all cool but you can code with notepad on anything so I don't think you NEED to get a laptop jsut to code well gl:tup:Zitat:
Zitat von _-Tiger-_
If you read the error that luaplayer gave you, you would see that on line 19 and 20 a variable called 'player' is used, yet it is not defined any where in the script. Remember, lua is case sensitive. 'Player' is not the same as 'player'. It is also linear, so things are interpreted from top to bottom.Zitat:
Zitat von Gam3freQ
Code:-- Test Lua Application
T_Player[1].x = 10; -- Undefined table
T_Player = {} -- Table defined after table-menu
ok so also if I fix this then will my Player width and height be the same as Mouse8's width and height? (look at the code for Mouse8) Thank you for all of thatZitat:
Zitat von _dysfunctional
I also got an error on line 35: error loading sound, so I saw that it sad flase instead of false, so I fixed it, and I got the same error
-= Double Post =-
ZOMG! I downloaded colors.lua from evilmana.com and realized that there are NO SPACES! If there arn't any spaces then that means they won't work! Also they don't work without the spaces I tried! oh no! is there an alternate download with the spaces because that's a good 1000 colors that are now goin to waste
yes it will....
the only thing spaces do are make your code look nicer
no it gave me error dudeZitat:
Zitat von michaelp
GhostWhite=Color.new(248, 248,255)
does not work BUT
GhostWhite = Color.new(248, 248, 255)
works perfectly and does NOT display error message so I said screw it and spaced out the ones I wanted to use and deleted the rest, and the program works, but I want to change the controls. I do NOT want it to be, up goes up, right goes right, left goes left, down goes down, etc. I want UP on the dpad to move your character whatever direction it is facing, and then left and right to turn or change the direction you're facing like in the flash game.
You could have just used search-replace to fix the spaces...
I'm having a bit of a problem with an image.
The image just looks like a button. (Sort of, not from the way I made it)
It has a black background, but when I blit it to the screen(without a background, or black) the background will show up as grey, not black.
I've tried using the True and false value's for the alpha, but same thing.
Anyone know why?
edit: nvm, fixed
i've been trying to find a way around this since saturday and i finally found one! yes its true that a screenshot will capture the scaled image but it would take way too long to write to the ms. remember the weird things that were happening with fillRect and print? well those weird things helped me to figure it out. when it blits from the screen, all it sees is alpha=0. when you fillRect or print before Gu.blit, it sees this as alpha=255. we can use this to our advantage to create masks! so in short, the quick fix is:Zitat:
Zitat von Merick
before the call to Gu.start3d()Code:screen:fillRect(x,y,image:width(), image:height())
:tup: :tup: :tup: :tup: :tup:
tell me howZitat:
Zitat von coolguy5678
Hows the game going? Im definatly gonna start learning Lua. I think ill start tomorrow, after i workout....gotta get ready for football lol
Ok well i am not normally a Lua dev i would rather work with C/C++ any day but i have to work in Lua for a little while (if you are active at the luaplayer forums you would know what i am working on). Ok well i have setup the GU in the luaplayer and have it all working but i am wanting to run opacity on my objects so natuarally i enable GU_BLEND and run a normal Gu BlendFunc with (GU_ADD GU_SRC_ALPHA GU_ONE_MINUS_SRC_ALPHA) but my draw back is with the Luaplayer Color object i believe. I think that it does not support an alpha value. please correct me if im wrong but how would i go about having an Color object of an object drawn at ~50% opacity
EDIT====
MY BAD I OVER LOOKED IT ON THE DOCUMENTATIONS
Search-replace (you do know how to use search-replace, right?) "=" with " = " (without the quotes).Zitat:
Zitat von Gam3freQ
ok guys... we've been doing some work on it and we've hit a problem. the bat doesn't appear and u can go offscreen.
can someone help plz.Code:-- ******* RODM: Run or Die Mouse ********
-- This was Made by Mraellis And GamefreQ for your learning purposes. Please do not steal our work, but
-- give us credit instead, and ask for our permission to use this.
-- Colors
cyan = Color.new(0, 255, 255)
red1 = Color.new(255, 0, 0)
salmon1 = Color.new(255, 140, 105)
burlywood4 = Color.new(139, 115, 85)
math.randomseed(os.time()) --/// prevent same random numbers from occuring each run of the game///
-- Images
Bat = Image.load ("Images/bat.png")
grass = Image.load("Images/Grass.png")
Mouse7 = Image.load("Images/Mouse_UL.png")
Mouse9 = Image.load("Images/Mouse_UR.png")
Mouse8 = Image.load("Images/Mouse_U.png")
Mouse2 = Image.load("Images/Mouse_D.png")
Mouse4 = Image.load("Images/Mouse_L.png")
Mouse6 = Image.load("Images/Mouse_R.png")
Mouse1 = Image.load("Images/Mouse_DL.png")
Mouse3 = Image.load("Images/Mouse_DR.png")
-- Sounds
Bat = Sound.load("Sounds/Bat.wav",false)
Mouse = Sound.load("Sounds/Mouse.wav",false)
Boom = Sound.load("Sounds/Boom.wav",false)
Chomp = Sound.load("Sounds/Chomp.wav",false)
heavyweight = Sound.load("Sounds/heavyweight.wav",false)
Shotgun = Sound.load("Sounds/Shotgun.wav",false)
Squash = Sound.load("Sounds/Squash.wav",false)
Levelstart = Sound.load("Sounds/Levelstart.wav",false)
-- Vars
Win = screen:print(200, 100, "Well Done, You Won!", red1)
Lose = screen:print(200, 100, "Sorry, You Lost!", cyan)
Score = screen:print(200, 100, "Your score is", salmon1)
MadeBy = screen:print(200, 100, "This Game was made by Mraellis And GamefreQ", burlywood4)
-- Tables (enemies and Players are here)
Player = { } Player = { x = 200, y = 50 }
Enemy = { } Enemy = { x = 50, y = 50 }
screenwidth = 480 - Mouse8:width() -- These are so you cannot move your character off the screen
screenheight = 272 - Mouse8:height() -- because the PSP screen has 480 x 272 pixels :)
function movePlayer() --/// function to move our player when directionals are pressed///
pad = Controls.read()
if pad:left() then
Player.x = Player.x - 5
end
if pad:right() then
Player.x = Player.x + 5
end
if pad:up() then
Player.y = Player.y - 5
end
if pad:down() then
Player.y = Player.y + 5
end
end
function chasePlayer() --/ function to make the enemy chase the player/
stallchase = math.random(2)
if stallchase == 1 then
if Enemy.x > Player.x then
Enemy.x = Enemy.x - 2
elseif Enemy.x < Player.x then
Enemy.x = Enemy.x + 2
end
end
stallchase = math.random(2)
if stallchase == 1 then
if Enemy.y > Player.y then
Enemy.y = Enemy.y - 2
elseif Enemy.y < Player.y then
Enemy.y = Enemy.y + 2
end
end
end --///end the function///
-- Main loop
while true do
screen:clear()
for a = 0, 14 do
for b = 0,8 do
screen:blit(32 * a, 32 * b, grass)
end
end
screen:blit(Player.x,Player.y,Mouse8)
screen:blit(Enemy.x,Enemy.y,Bat)
movePlayer() --///call movePlayer function///
chasePlayer() --///call chasePlayer function////
screen.waitVblankStart()
screen.flip()
end
ok guys... we've been doing some work on a game and we've hit a problem. the bat doesn't appear and u can go offscreen.
can someone help plz.Code:-- ******* RODM: Run or Die Mouse ********
-- This was Made by Mraellis And GamefreQ for your learning purposes. Please do not steal our work, but
-- give us credit instead, and ask for our permission to use this.
-- Colors
cyan = Color.new(0, 255, 255)
red1 = Color.new(255, 0, 0)
salmon1 = Color.new(255, 140, 105)
burlywood4 = Color.new(139, 115, 85)
math.randomseed(os.time()) --/// prevent same random numbers from occuring each run of the game///
-- Images
Bat = Image.load ("Images/bat.png")
grass = Image.load("Images/Grass.png")
Mouse7 = Image.load("Images/Mouse_UL.png")
Mouse9 = Image.load("Images/Mouse_UR.png")
Mouse8 = Image.load("Images/Mouse_U.png")
Mouse2 = Image.load("Images/Mouse_D.png")
Mouse4 = Image.load("Images/Mouse_L.png")
Mouse6 = Image.load("Images/Mouse_R.png")
Mouse1 = Image.load("Images/Mouse_DL.png")
Mouse3 = Image.load("Images/Mouse_DR.png")
-- Sounds
Bat = Sound.load("Sounds/Bat.wav",false)
Mouse = Sound.load("Sounds/Mouse.wav",false)
Boom = Sound.load("Sounds/Boom.wav",false)
Chomp = Sound.load("Sounds/Chomp.wav",false)
heavyweight = Sound.load("Sounds/heavyweight.wav",false)
Shotgun = Sound.load("Sounds/Shotgun.wav",false)
Squash = Sound.load("Sounds/Squash.wav",false)
Levelstart = Sound.load("Sounds/Levelstart.wav",false)
-- Vars
Win = screen:print(200, 100, "Well Done, You Won!", red1)
Lose = screen:print(200, 100, "Sorry, You Lost!", cyan)
Score = screen:print(200, 100, "Your score is", salmon1)
MadeBy = screen:print(200, 100, "This Game was made by Mraellis And GamefreQ", burlywood4)
-- Tables (enemies and Players are here)
Player = { } Player = { x = 200, y = 50 }
Enemy = { } Enemy = { x = 50, y = 50 }
screenwidth = 480 - Mouse8:width() -- These are so you cannot move your character off the screen
screenheight = 272 - Mouse8:height() -- because the PSP screen has 480 x 272 pixels :)
function movePlayer() --/// function to move our player when directionals are pressed///
pad = Controls.read()
if pad:left() then
Player.x = Player.x - 5
end
if pad:right() then
Player.x = Player.x + 5
end
if pad:up() then
Player.y = Player.y - 5
end
if pad:down() then
Player.y = Player.y + 5
end
end
function chasePlayer() --/ function to make the enemy chase the player/
stallchase = math.random(2)
if stallchase == 1 then
if Enemy.x > Player.x then
Enemy.x = Enemy.x - 2
elseif Enemy.x < Player.x then
Enemy.x = Enemy.x + 2
end
end
stallchase = math.random(2)
if stallchase == 1 then
if Enemy.y > Player.y then
Enemy.y = Enemy.y - 2
elseif Enemy.y < Player.y then
Enemy.y = Enemy.y + 2
end
end
end --///end the function///
-- Main loop
while true do
screen:clear()
for a = 0, 14 do
for b = 0,8 do
screen:blit(32 * a, 32 * b, grass)
end
end
screen:blit(Player.x,Player.y,Mouse8)
screen:blit(Enemy.x,Enemy.y,Bat)
movePlayer() --///call movePlayer function///
chasePlayer() --///call chasePlayer function////
screen.waitVblankStart()
screen.flip()
end
because you have a bat image, and a bat sound that are named the same
you never put in a function or anything so that the bat/mouse can't go offscreen
also, with all those sounds and pictures, don't you get some sort of memory error, or the game is a bit slow?
also, a suggestion for your "movePlayer" function: make it less than + or - 5, that (i think) will be quite choppy
Your variables should be:
1. functions
or
2. just words
I'm pretty sure you can't be a built-in luaplayer function in a variable
just put the words you want in, and when you want to print it to the screen, do this:
screen:print(x, y, variable, colour)
DONT ARGUE. it doesn't work i have tred it OK?! also look at the post above and help us with that source code somebody, and I do not know how to do "find and replace" or w/eZitat:
Zitat von michaelp
i'll explain f & r later
oh okZitat:
Zitat von mraellis
:Punk:
Hey does anyone know how to edit my code while having it on my psp w/o exiting Luaplayer? I've tried this
System.usbDiskModeActivat e()
But i cant edit my code... any help?
Edit: Ok im following tutorial #2 from psp-programming.com and when i try it i says
Error SCRPIT.LUA:130: /=/ expected near /pad/. Any help?
look at line 130 in your codeZitat:
Zitat von _-Tiger-_
I did i tried to fix it about 10 times and still nothing... lol
post the full code and we can see where the problem is
Thanks for the tip, I was wondering about that.Zitat:
Zitat von Da_MerV
Also, here's Gu.blit2:
it's basically the same as the first Gu.blit, except this version can draw parts of the image:Code:function Gu.blit2(x, y, image, img_x, img_y, width, height, scale, flip)
if not scale or type(scale) == "string" then
flip = scale
scale = 1
end
if flip then
if flip == "H" then
x_start = img_x + width
y_start = img_y
x_end = img_x
y_end = img_y + height
elseif flip == "V" then
x_start = img_x
y_start = img_y + height
x_end = img_x + width
y_end = img_y
elseif flip == "HV" then
x_start = img_x + width
y_start = img_y + height
x_end = img_x
y_end = img_y
end
else
x_start = img_x
y_start = img_y
x_end = img_x + width
y_end = img_y + height
end
width = (width*scale)+y or (image:width()*scale)+x
height = (height*scale)+y or (image:height()*scale)+y
temp = {
{x_start, y_start, x, y, 0},
{x_end, y_end, width, height, 0}
}
Gu.enable(Gu.TEXTURE_2D)
Gu.texImage(image)
Gum.drawArray(Gu.SPRITES, Gu.TEXTURE_32BITF+Gu.VERTEX_32BITF+Gu.TRANSFORM_2D, temp)
end
Gu.blit2(10, 10, image, 10, 10, 40, 90, 1.5, "HV")
are you sure you completely exited your app or game and were in Lowser when trying to edit your code?Zitat:
Zitat von _-Tiger-_
Once you edit your going to need to quit your game and restart lowser.
you dont need to restart lowser, just exit the app then restart the app after editing it.Zitat:
Zitat von Anti-QuickJay
Thats if you include a exit call.