|
#1
|
||||
|
||||
|
Hi everybody.
Its about the same game like before. Mac attack. But now I want to draw a variable to the screen just like the score in the middle. The edited stuff is red: Code:
--Draw game (All erasing of images need to be performed before the next set is drawn out.
function drawGameScreen()
newtime = gettime()
if (newtime - oldtime) > 36 then
moveTargets() --Move the game forward
oldtime = gettime()
for i=1,#target do --Go through all positions with a target and erase it's image.
screen.fillrect(target[i].x,target[i].y+target[i].speed,40,44,black)
end
screen.fillrect(50,180,140,40,black) --Draw out score in the center of the screen
text.size(40)
text.color(dGray)
text.draw(0,180,score,"center",240)
text.color(-12)
text.draw(0,350,newtime,"center",240)
screen.update()
for i=1,#target do --Go through all targets and draw them in their designated place and state
target[i].get.img[target[i].state]:draw(target[i].x,target[i].y,40,44)
end
screen.update()
end
end
http://img683.imageshack.us/i/howcanifixit.jpg/ -Wood |
|
|
|||
|
|
|
#2
|
||||
|
||||
|
After going over every part of your red code, it is fine. i put it in my skifree code and works. from the looks of the picture it seems the text just isnt clearing.
you have screen.fillrect(50,180,140,40,black) but not one for your new drawing
__________________
Tools: Playlist Manager , Document to RSS , Notepad++ Instellisense Games/Apps: Asteroids, ZenFrame, Graphing Calculator, Pingus X-Fi2, Boxwars, SkiFree, Jezzball |
|
#3
|
||||
|
||||
|
Yeah ty. Now it works fine.
Do you know how I can change this "60000 seconds" value to a real timecode? Like: "59 seconds left!" That would be nice because it looks a lil bit to much like a variable. |
|
#4
|
||||
|
||||
|
im not sure what you mean can you elaborate more?.
__________________
Tools: Playlist Manager , Document to RSS , Notepad++ Instellisense Games/Apps: Asteroids, ZenFrame, Graphing Calculator, Pingus X-Fi2, Boxwars, SkiFree, Jezzball |
|
#5
|
||||
|
||||
|
Yes no prob.
The variable newtime = 60000. But in the game it should be look like: "01:00 minute left" not "60000 milliseconds left". LIKE HERE <- And how do I reset the newtime variable to 0 when the 1min is over? |
|
#6
|
||||
|
||||
|
here use this
hours = math.floor(newtime /3600000) minuts= math.floor(math.fmod(newtime ,3600000)/60000) seconds = math.floor(math.fmod(newtime ,60000)/1000) miliseconds= math.floor(math.fmod(newtime ,1000)/10) and each variable is set acordingly, auto resets and everything
__________________
Tools: Playlist Manager , Document to RSS , Notepad++ Instellisense Games/Apps: Asteroids, ZenFrame, Graphing Calculator, Pingus X-Fi2, Boxwars, SkiFree, Jezzball |
|
#7
|
|||
|
|||
|
JBob-
Is the math (class(module?)) part of lua api or c standard? Also is there a random (class(module?)) in lua one can utilize in a program? |
|
#8
|
||||
|
||||
|
Math is a standard library in LUA. You can use math.random(min, max) to generate pseudo random numbers. I'd recommend you to use math.randomseed(os.ostime()) once to alter the permutations of your random numbers before using math.random.
__________________
Zen X-Fi2 Apps: Notee-fi (notepad) | TicTacToe | Mahjongg http://www.starfare.eu/ - a free real-time strategy game. |
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 02:44 PM.











Linear Mode
