its two countdown timers!Zitat:
Zitat von Altair
so i could use pics, but its not something i favour.
i've got some work to do on my bonus features.
but its something im considering.
Printable View
its two countdown timers!Zitat:
Zitat von Altair
so i could use pics, but its not something i favour.
i've got some work to do on my bonus features.
but its something im considering.
One thing you could do is, you have all the numbers saved as a seperate image. Then you blit the right one at the right places. Hope thats clear enough.
Zitat:
Zitat von Altair
yeah thats what I was just talking about. :)
yeah i see now, sorry. I read montrobs reaction after yours and he doesn't use this, i think. I should have added "@Montrob" before my post.
LOL, no worries,
thanks for the help, i'll be needing lots more later on Im sure. :)
guys i m stuck in something
http://img111.imageshack.us/img111/7...tvalley1gf.jpg
look at the picture
I made the square boxes to make the player picture moves to be false if it tries to get through the boxes and i made player moves to be true if its at the left side and bellow of the boxs.
The code above will make player picture to go up if its bellow the box and to the left side of the boxes as its showing at the picture above.Code:if moving1 == false and x0 <= block[c].x-14 and x0 >= block[c].x-16 and y0 >= block[c].y+16 then
moving1 = true
end
At the picture above, player picture moves is true becuase its left side and bellow the box.
The problem is:
If there is another box at the left side of the 3 boxes so its above the player picture, player picture will try to get through the box but it stops when it pass 1-2 pixels.
my question is? Is there a code that i can add in the code above to make the moving1 = true if it reads the color of the background to the left side of any box ?
so if it dosent match the background color to the left side of a box, the player1 will not move up
~Edit like this code bellow for an example, i added "white == screen:pixel(block[c].x-14, block[c].y)" but it dosent work
Code:if moving1 == false and x0 <= block[c].x-14 and x0 >= block[c].x-16 and y0 >= block[c].y+16 and white == screen:pixel(block[c].x-14, block[c].y) then
moving1 = true
end
Could it be this part:Zitat:
Zitat von natan333
Are you sure you meant for "x0" to be specifically in between those two #s?Code:x0 <= block[c].x-14 and x0 >= block[c].x-16
That means "x0" can only equal one number at all for "moving1" to be true.
Zitat:
Zitat von EminentJonFrost
if it dosent have "y0 >= block[c].y+16" picture player that have x0 and y0 axis will bypass any box and not bypass the corners bellow. and if it dosent have "x0 <= block[c].x-14 and x0 >= block[c].x-16 " it will just go through the box.
the code i put works great but my question is what code i put to read the white background color to the left side so the white background will also be needed to make moving up true
no no, look, I'm saying you limited that "moving1" to be true ONLY ifZitat:
Zitat von natan333
"x0" is 14 < x > 16
see?
the chances are very narrow.
at least I'm guessing, i dont what "x0" would equal otherwise.
as for the "y0", I said nothing of it.
If you are saying you want moving1 to be true if the background is white, then can't you do:Zitat:
Zitat von natan333
I think that is what you meant, but I kept getting more :confused: as I kept re-reading it.Code:if screen:blit(480,272,white) == true then
moving1 = true
end
Zitat:
Zitat von EminentJonFrost
from what it shows in my psp, the "x0" is 14 < x > 16 is telling to be true outside of the box to the left and right but it makes bug if there is more then 2 boxes close together so y0 >= block[c].y+16 makes to be left only to be true
like that is for the whole background. i want to make like a 16x , 16y invisible square to the left of all box so if its white in that invisible square, it becomes true for moving1 and if there is another color, it dosent do nothingZitat:
Zitat von PSPduh
does anyone know why my scripts keep getting an error because 'there is no loop to break'? The thing I have (by help of Jon Frost) is that at the beginning of a function it says :
if quit == true then
break
end
What is wrong with it, and why can't it break the function loop?
Also, I just took that part out of my code, saved and retried the program, yet it had the same error? I am so confused.
Think my friend...... think... break = break a loop = has to be in a loop... Not neccessarly a function...
Basically, just put the 'if' statment for breaking the loop in the/a loop
hmm
how can i make the opposite of
Code:if moving1 == false and x0 >= block[c].x+16 and y0 >= block[c].y+16 then
moving1 = true
end
The opposite of that?Zitat:
Zitat von natan333
(This is assuming you want "moving1" to be false again.)
That what you mean?Code:if moving1 ~= false and x0 >= block[c].x+16 and y0 >= block[c].y+16 then
moving1 = false
end
I'll take another look at it.Zitat:
Zitat von emericaska8r
EDIT - emericaska8r, check your PM or email.
i think that that is what he means...
I think so too, but I've been wrong before.Zitat:
Zitat von Glynnder- PSPro
This code makes the player moving1 (up) to be true if its at the right side of the block and bellow itCode:if moving1 == false and x0 >= block[c].x+16 and y0 >= block[c].y+16 then
moving1 = true
end
i want to change the right to left.
How is it stuck if the player it isnt touching and is not going to touch a block?Zitat:
Zitat von natan333
I'm gonna go back read over everything again. This is confusing me. Plus, the way you explain it (no offense) is not helping.
EDIT - OOOOOOHHHHH!! Ok. I get it now.
All right, you want it luaplayer to check if theres a block in the way of the player, and if there is, the player cannot go through it. Makes sense. It was harder to understand that since some parts of your post were repetitive.
Ok, umm...all right, heres an example:
does that help you?Code:-- box is 20x20 pixels
box_x = 100
box_y = 100
box2_x = 120
box2_y = 120
--[[this means the box will cover from:
(100, 100)____________(120, 100)
|
|
|
|
|
(100, 120)_____________(120, 120) <bottom right of pic
]]
if player_x > box2_x or player_x < box_x and player_y > box2_y or player_y < box_y then
can_move = true
end
if player_x >= box_x and player_x <= box2_x then
can_move = false
end
if player_y >= box_y and player_y <= box2_y then
can_move = false
end
Ok, thanks jon frost. I'll try and look at it from here to make it better.
Zitat:
Zitat von EminentJonFrost
not sure. becuase i m using
Code:block = {}
block[1] = { x = 34, y = 190 }
for d = 2, 4 do
block[d] = { x = block[d-1].x + 16, y = 150 }
end
like the code bellow makes move up to be false if it touch the bottom of my 17x17 pixel box
but the problem is that if there is 3 boxs close with the same y axis but different x axis, the 1st at the right will work normally.Code:for c = 1, 4 do
screen:blit(block[c].x, block[c].y, blockk)
Code:
if moving1 == true and x0 > block[c].x-14 and x0 < block[c].x+16 and y0+10 > block[c].y and y0 < block[c].y+17 then
moving1 = false
end
---like in the code bellow, if the moving picture is at the left side of the box and bellow it, it becomes true
Code:
if moving1 == false and x0 < block[c].x-13 and y0 > block[c].y and y0 < block[c].y+17 then
moving1 = true
end
end
the 1st and 2nd of the left move up will be true because the 1st at the right is making it to be true
the thing i dont get it is to make it check if it have a box above the moving picture (that is x0 and y0)
so if there is a box above its false. if there is no box above its true for the moving picture to go up
so then do what your saying... its just booling really
I need some help.
Can someone explain me screen:drawLine to me VERY detailed? Because I need this to complete something that I'm making. Also, can somebody explain me screen:fillRect too? Thank you.
--PSPduh
How do you call a variable from a table .. thats within a table?
What I mean by "how do I call it" is...well, ok, to call a variable from a table, you just do this:
so how would I call that same variable if its table were inside another table?Code:table = { variable1, variable2 }
table.variable1 -- there, called the first variable from table "table".
Code:bigger_table = {
table = { variable1, variable2}
table2...blah blah
}
Hey I was wondering what kind of software or whatever could create a .png image with a transparent background, so it wouldn't be all white, it would just be unnoticable. This is because I created one, yet when i saved it as .png my software said that it could save it in .png, yet it wouldn't retain all features. When i opend it again, it had a white, not transparent background. How would i do this?
The GIMP.Zitat:
Zitat von emericaska8r
To find it, go to Google.
dont worry, its free.
Ok, you need to get a runtime environment before the actual painting app, but its in the same site, so its not a problem.
all right now, once its installed, open it.
open up a photo. (its comes in it own window.)
on the top it says: File Edit Select ... blah blah
go to "Layer"
scroll down to "Transparancy"
to the side, go to "color to alpha"
then you pick a color in your image that will become transparent.
oh yea, it does .png pics. (and LOTS more.)
Zitat:
Zitat von EminentJonFrost
i dont think youre even allowed to do that. i would just make two seperate arrays/tables.
Yes you are allowed... Not in LUA though... nad it sounds to me like your making a class, which is in C(?)/C++ so far...
But you can always do a multilayered table/array... I dunno if LUA supports it but...
example[3][3] = ( '1', '2', '3'
'4', '5', '6'
'7', '8', '9'
;}; example
Its something like that... that is for a tic-tac-toe board... so i dunno if LUA can support even this, let alone classes...
sorry, no help here =(
:(
thanks for trying.
but I know its possible.
Luaplayer's own game "snake" has this piece of coding in it to prove it:
Code:...
-- possible options for menu
possibleOptions = {
speed = {
displayName = "Speed",
values = { 1, 2, 3 } },
level = {
displayName = "Level",
values = { "grass", "desert" } },
music = {
displayName = "Music",
values = { "on", "off" } },
sound = {
displayName = "Sound",
values = { "on", "off" } }
}
...
I think "example[3][1]" works (where [3] is the second table thats on the 3th place in the big table and [1] is the first value in the second table), but Im not completely sure.
Have you tried to just use: "bigtable.table1.valu e"? Maybe that works aswell.
i thought about it, but no I havent tried that. I will right now...
edit - nevermind, I'm just gonna make a new table. I'll figure it out later.
One last thing, I have the enemy's "y" location set to math.random(272). making it appear randomly, but how come it appears at the same place everytime I start the game up?
Zitat:
Zitat von EminentJonFrost
put this at the VERY top of you code:
it should give you different numbers now.Code:math.randomseed(os.time())
It worked!
But why?
Zitat:
Zitat von EminentJonFrost
that function make the random numbers based on the time, which isnever the same. without it, the psp ram recalls the number it got last time, cause it gets kinda "lazy". i dont relly know how to exxplain it, but hey, it works!
^^what he said it's especially great for luawindows
oh.
thanks for explaining it!
BTW, I think I found out how to call variables from tables that are inside tables.
"table name" [#] .(dot) "variable"
Code:example:
a = { b, c = { d } }
a[2].d
yes or like so:
table = {}
table[1] = {x = 5}
table[2] = {y = 6}
screen:blit(table[1].x,table[2].y,image)
i use mine this way(onle an example)
that way looks easier. more organized, easier to find what you want.Zitat:
Zitat von slicer4ever
I'll do it like that.
it makes things much more easier as you said especially to understand everything