android
  #1  
Old 12-31-2010, 11:06 AM
WooDChecker's Avatar
WooDChecker WooDChecker is offline
Junior Member
 
Join Date: Dec 2010
Location: Germany
Posts: 35
Default Draw variable

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
I hope you can see whats wrong with the code because it looks:
http://img683.imageshack.us/i/howcanifixit.jpg/


-Wood
Reply With Quote

Advertisement [Remove Advertisement]

  #2  
Old 12-31-2010, 12:26 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default

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
Reply With Quote

  #3  
Old 12-31-2010, 01:23 PM
WooDChecker's Avatar
WooDChecker WooDChecker is offline
Junior Member
 
Join Date: Dec 2010
Location: Germany
Posts: 35
Default

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.
Reply With Quote

  #4  
Old 12-31-2010, 02:12 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default

im not sure what you mean can you elaborate more?.
Reply With Quote

  #5  
Old 12-31-2010, 02:35 PM
WooDChecker's Avatar
WooDChecker WooDChecker is offline
Junior Member
 
Join Date: Dec 2010
Location: Germany
Posts: 35
Default

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?
Reply With Quote

  #6  
Old 12-31-2010, 03:29 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default

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
Reply With Quote

  #7  
Old 01-01-2011, 01:28 PM
rgdevelops rgdevelops is offline
Junior Member
 
Join Date: Dec 2010
Posts: 2
Default

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?
Reply With Quote

  #8  
Old 01-02-2011, 08:41 AM
ZaPx64's Avatar
ZaPx64 ZaPx64 is offline
Member
 
Join Date: Nov 2009
Location: Germany
Posts: 136
Default

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.
Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 11:45 PM.