Well if you want 30 squares moving around, you're either gonna be usin a good bit of cpu to do it unless they all move equally and are on one image and that image then moves.
Printable View
Well if you want 30 squares moving around, you're either gonna be usin a good bit of cpu to do it unless they all move equally and are on one image and that image then moves.
I'm making a program where the user can view images (don't worry, it's not ordinary). How can I make it so that even though the program doesn't include the images' name, it can blit it to the screen?
Oh, thats a good question. What I would do until that question is answered is just make them rename the files to whatever you want them to be called and is included in your script.
Yeah, for my first version, I'll do that.Zitat:
Zitat von psp11
Scan the directory for files and display the files that have the image extensions. Look at Lowser's ( the LuaPlayer Lua file broswer ) source on how to do that.
Xploren, first of all you gotta make yourself a filebrowser. Then you gotta add in a script to view pics. Heres that filebrowser i wrote a while back if youd like to take a look:
Spoiler for Filebrowser:
It would be cool to work on a project with you.Zitat:
Zitat von eldiablov
I'm not the best drawer, (isint that the thing where you keep you clothes?) but i can make pretty good GFX.
It would also be a good opputinity to learn more. But you have to fix your msn... =D
Lol okay then i'll fix it. :Argh:
Anyway come on msn and we can work together
Aight guys i wont be here for a few days to help you with stuff so stop PMing me until you see me on the forums ok? ill probly be back monday. thanks!
Ok, May i ask where are you going?Zitat:
Zitat von -TacticalPaper-
Do you care???
jk
Yes i do.:tup:
After about half an hour of changing values in this example from the lua snippets thread, i've basically got how this code works. but does anyone know how to fill in the circle?
Code:--[[Drawing a circle
Created by FxN
This draws a circle and takes 5 arguements:
1.Target = What we are drawing on
2.X coordinate
3.Y coordinate
4.Radius of the circle
5.Color
The X and Y coordinates are for the middle point of the circle]]
function drawcircle(target, ux, uy, crad, ccolor)
degree = 0
while degree < (6.4) do
target:pixel((math.floor(crad * math.cos(degree)))+ ux, (math.floor(crad * math.sin(degree))) + uy, ccolor)
degree = degree + 0.005
end
end --drawcircle
---circle function
screen:clear()
drawcircle(screen,100,100, 50, red)
screen.flip()
while not Controls.read():cross() do
screen.waitVblankStart(1)
end
that doesnt workZitat:
Zitat von -TacticalPaper-
--exitpart--
if pad:select() then break end
That part in tactical's code should be
if pad:select() then
break
end
-= Double Post =-
I see a lot of arguments in there that need to be on thier own lines. So just check the code. like
if s > nf then s = 1 end
if s < 1 then s = nf end
needs to be
if s > nf then
s = 1
end
if s < 1 then
s = nf
end
they dont have to be their own lines.
i got it to work, i just defined white wrong.
I just got told :Cry:
something is wrong...
in my code i have this at the end:
time = time + 1
and i have this in the code:
if time > 1200000 then
part = part +1
time = 0
end
but it scrolls way to fast. what is going on?
Cant really tell from the code you provided. Not to mention I dont understand your problem that well.
Spoiler for Code:
i made it so when you select a folder and hit triangle, it will go through the images in that folder one by one. but once i hit triangle, it goes through them super fast
add some kind of delay, be it a timer or something else.
I did that is what "time" is.
Umm, no. You don't need to have each part on a seperate line. I put stuff all on one line to reduce the number of linesw i gotta count when i get errors.Zitat:
Zitat von GuitarGod1134
what about my timer problem? i tried it like this:
Spoiler for code:
yet it still goes super fast through my images
Dracule: What are you trying to do, add a slideshow feature to it or what?
yeah, i was experimenting with it... and am trying to get to have a slide show through all the images in the folder of your choice. so when you are in the folder with your pictures, you hit triangle and it should go through them one by one. but it blazes through them.
have you just tried to increase the number that the time must go up to?Zitat:
Zitat von dracule
so instead of:
useCode:if time > 12000
hm.. but then again i dont see why 12000 should go that fastCode:if time > 300000
-= Double Post =-
hey this part of your code,
could that be why. i don't really know what it does, but that may be making it got too fast also, since it also has an (s = s + 1)Code:if string.sub(fl[s].name, -4) ~= ".png" or string.sub(fl[s].name, -4) ~= ".jpg" or string.sub(fl[s].name, -4) ~= ".PNG" or string.sub(fl[s].name, -4) ~=
".JPG" then
if ready == 1 then
s=s+1
end
end
-= Double Post =-
ok, nvm i see that it just has that to skip it if the image isn't one of those two types. sry
[continuing from my last post]
i guess i could make a whole bunch of circles until it fills up, but that just seems too impractical.
edit - (now i'm just posting for future reference) to make new circles to fill up the first one, i just repeatedly do the 'drawcircle' function while changing the circle's radius value so the circle's get smaller, thereby filling the empty hole there once was. even though that works, i'm still waiting to see if anyone knows another way to do this.
I have no idea why it goes that fast. i could set it to 1000000000000000000 and it still goes fast.Zitat:
Zitat von emericaska8r
Hey, I need some help.
How would I use the analog stick to control my character on the screen?
this is the code I have now using the arrows, but I dont like these controls much.
Code:function MovePlayer()
pad = Controls.read()
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
end
all right, the first thing you need to know about the analog stick is that it doesnt work like the other buttons in that you do "if pad:something then". no. instead, the analog stick has two continous..err..values (that word!!! i use it ALOT) 'X' and 'Y', 'x' for how far it is placed to the side of its original position and 'y' for how far up or down it is.Zitat:
Zitat von Nicko01
this is how you get those...values:
now when you move the analog stick up, variable2's .. value should go down (cause as 'y' increases the lower the position on the screen, i dont know why, pisses me off sometimes...lol) and as you move the analog stick right, variable1 should increase. the inverse happens when you move the stick the opposite way.Code:variable1 = pad:analogX()
variable2 = pad:analogY()
with those two variables, you can now make 'if' statements or whatever to make whatever you want happen with the analog stick! :tup:
i should note though, i dont know if its just me, but my analog stick isnt fully centered, so when its at rest, my 'x' is like 15. so you should be aware of that. hope that helps :)
Thanks a lot!
Time to get to work...
i was right about this code being impractical it seems. this code does work, but it GOBBLES up ram. the circle doesnt even inch forward, it more like millimeters forward, if it feels like it. but then i took out 7 of the 8 times i use the function and now it inches forward, still taking forever. i'm sure its a memory issue because everything works, just real slowly, including the home button.
Code:x = 100
y = 100
function drawcircle(target, x, y, radius, ccolor)
degree = 0
while degree < (6.4) do
target:pixel((math.floor(radius * math.cos(degree)))+ x, (math.floor(radius * math.sin(degree))) + y, ccolor)
degree = degree + 0.005
end
end
while true do
screen:clear(black)
pad = Controls.read()
analog = { x = pad:analogX(), y = pad:analogY() }
if pad:start() then
break
end
if analog.x > 20 then
x = x + 1
end
if analog.x < -20 then
x = x - 1
end
if analog.y > 20 then
y = y - 1
end
if analog.y < -20 then
y = y + 1
end
drawcircle(screen, x, y, 8, gray) -- there used to be 8 of these, but with another number in place of '8'.
screen.flip()
screen.waitVblankStart()
end
Use a buffer and itll only be moving one image so it should work better.
how would i use a buffer here?
Add in
buffer = Image.createEmpty(width,h eight)
Then instead of drawing your 8 circles to the screen EVERY loop, just draw them to the buffer once as the game is loading
drawcircle(buffer, x, y, 8, gray)
drawcircle(buffer, x, y, 7, gray)
drawcircle(buffer, x, y, 6, gray)
etc
Then blit the buffer to the screen and itll put the circle there as well.
so i guess no one can help me with my problem, aw well....
Sticky.:tup:
Ok I got a huge amount of code here and Im getting a lot of errors can someone help? Also I know my attempt at side scrolling is very bad can someone help me there too?
Spoiler for Code:
-= Double Post =-
O and my collision sucks a lot too. I know how to do that though so you dont have to tell me.
now i'm really stumped. i get an error at line 14 (i'll show you it in a bit) 'an argument was incorrect'. whats odd is that the error only comes up when i try to add in the buffer. if i have it normal (normal as in the crawling slow way i had it before) its fine, error free.Zitat:
Zitat von TacticalPenguin
i went back to page 444 of this thread and went through this again and i see nothing wrong.
i removed irrelevant code, it was nothing much, just movement controls.Code:x = 5
y = 5
playerbuffer = Image.createEmpty(10, 10)
function drawcircle(target, x, y, radius, ccolor)
degree = 0
while degree < (6.4) do
target:pixel((math.floor(radius * math.cos(degree)))+ x, (math.floor(radius * math.sin(degree))) + y, ccolor) -- This is line 14
degree = degree + 0.005
end
end
drawcircle(playerbuffer, x, y, 5, white)
while true do
screen:clear(black)
pad = Controls.read()
screen:blit(x, y, playerbuffer)
screen.flip()
screen.waitVblankStart()
end
-= Double Post =-
um...i think you should shorten that a bit, or at least say what errors you get. just looking at it discourages people to help just from its size. plus we dont know what to look for either. help us help you. :) lolZitat:
Zitat von GuitarGod1134