Timer for game program.

Hello all,
I am making a game program and I need a way to implement a timer so that it the game will end if the time expires.
Is there any easy function to help me with this task?

Thanks for the reply and I just found that class.
Thanks

Similar Messages

  • Validate/madatory  in order to avoid  long time for the program execution.

    Below is my selction screen.  I would like to do validations for specific fields to make them mandatory fields   as well.
    Could you please suggeste me what are the fields that I can validate/madatory  in order to avoid  long time  for the program  run.
    *Program selections
    SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-h01.
    SELECT-OPTIONS : o_as4loc   FOR v_as4local,
                     o_ddlang   FOR ddlanguage,
                     o_vkorg    FOR vkorg     MEMORY ID vko,
                     o_auart    FOR auart              MEMORY     ID aat,
                     o_fdnam    FOR fdnam,
                     o_spart    FOR spart   MEMORY ID spa,
                     o_vbeln    FOR vbeln            MEMORY ID aun,
                     o_posnr    FOR posnr,
                     o_matnr    FOR matnr            MEMORY ID mat,
                     o_pltyp    FOR pltyp            MEMORY ID vpl,
                     o_j_3ar    FOR j_3arqda,
                     o_kzr00    FOR kbetr,                       " -ZR00
                     o_kalsm    FOR kalsmasd,
                     o_kmwst    FOR kbetr,                       " -MWST
                     o_kbmen    FOR kbmeng,
                     o_land1    FOR land1            MEMORY ID LND
    SELECTION-SCREEN  : END OF BLOCK b1.
    Thanks in advance.

    Hi,
    Make key fields as well as fields on which there in an index in the database table mandatory.
    Regards,
    Abhijit G. Borkar

  • Ideal execution time for any program

    Hi,
    Is there any method to determine the ideal execution time for a program ?
    Or else how to determine that ?
    I just wanted the max. time that a program can take so that the performance would not be hampered.
    Thanks,
    Binay.

    did you ask for the 'ideal execution time' or 'how to measure execution times'?
    The second question was answered in one of your other questions.
    Optimization:
    Do SQL Trace, go to Summary by SQL statement, check 10 Top contributions (time = duration).
    Try to optimize them, note minimal time per record, if larger than 10.000 microsecodns, then you should index usage.
    Do SE30, go to hit list, sort by net time, again address 10 Top contributions, try to optimize, check the coding.
    Do optimization and trace again, check again 10 Top contributions ....
    Siegfried

  • Recommend me SDK for game programming

    I need a 3D SDK with audio support. Obviosly it would be Java3D. But i've heard it uses much memory, and it's complicated.
    What do you think about j Monkey Engine ?
    Or is Java3D the right choice for game programming ?

    You'll probably get better responses on the game programming board
    http://forum.java.sun.com/forum.jspa?forumID=406

  • How to know which sql query is taking time for concurrent program

       Hi sir,
    I am running concurrent program,that is taking time to execute ,i want to know which sql query causing performance
    Thanaks,
    Sreekanth

    Hi,
    My Learning: Diagnosing Oracle Applications Concurrent Programmes - 11i/R12
    How to run a Trace for a Concurrent Program? (Doc ID 415640.1)
    FAQ: Common Tracing Techniques in Oracle E-Business Applications 11i and R12 (Doc ID 296559.1)
    How To Get Level 12 Trace And FND Debug File For Concurrent Programs (Doc ID 726039.1)
    How To Trace a Concurrent Request And Generate TKPROF File (Doc ID 453527.1)
    Regards
    Yoonas

  • How create timer for game?

    I want to know how much time player spend in the game.
    For this i want create a timer.
    I thing it must be something like this:
    player come to the game (time 0:00), player plaing for example 22 minutes, gameover game (player spend 22 minutes and 0 sec).
    code:
    import flash.utils.getTimer;
    var gameStartTime:uint;
    var gameTime:uint;
    var gameTimeField:TextField;
    function mainFunction():void
         gameTimeField = new TextField();
         addChild(gameTimeField);
         gameStartTime=getTimer();
         gameTime=0;
         addEventListener(Event.ENTER_FRAME,showTime);
    function showTime(event:Event)
         gameTime=getTimer()-gameStartTime;
         gameTimeField.text="You plaing: "+clockTime(gameTime)+"min";
    function clockTime(ms:int)
         var seconds:int=Math.floor(ms/1000);
         var minutes:int=Math.floor(seconds/60);
         seconds-=minutes*60;
         var timeString:String=minutes+":"+String(seconds+100).substr(1,2);
         return timeString;
    mainFunction();
    Is this correct way?
    If you know how to make code smaller can you please share?
    Maybe exist standart component or something else for this?
    Thank you.

    Thank you guys!
    Just asking how to make timer correct:)
    I thout maybe you know existing standart coder or standart component for it?
    For example i use the same timer for 5 games.. and for every game i need create code..  Is it possible to make code just one time and create something like standart components in Flash IDE ? Or maybe adobe have place where everyone can create components and share whit other? Or its all not possible, and need create the same code again?
    By the way why i dont see my secons here?:
    var gameStartTime:uint;
    var gameTime:uint;
    function mainFunction():void
         gameStartTime=getTimer();
         gameTime=0;
         addEventListener(Event.ENTER_FRAME,showTime);
    function showTime(event:Event)
         gameTime=getTimer()-gameStartTime;
         myText.text="Time: "+clockTime(gameTime);
    function clockTime(ms:int)
         var seconds:int=Math.floor(ms/1000);
         var timeString:String=String(seconds+100).substr(1,2);
    mainFunction();

  • Measure time for a program in SE30 transaction code

    where should i get the help files and i want to know  how should we measure the time for the two different programs and upto how much time the program will take if the program is exactly right means with no errors and in the graph it is showing when i'm analyzing the performance of a program i.e abap with 77% in red, database with 10% in green, and system with 20% in green what does it represent. for a exactly correct program how much percentage should  needed and it should be in which color?

    Hi,
    for a good program,
    the database and system time values should be green always.
    abap program can be red also not a problem.
    but if database is in red colour, (after it crosses 50%), then it means that it gives much load in database server and you should change your code performance.
    Regards,
    Sakthi Sri.

  • Why do i need to declate methods two times for this program work

    Hi,
    why should i have to declare 2 times the methods
    public void mouseClicked(MouseEvent e) {    }
    public void mousePressed(MouseEvent e) {    }
    public void mouseReleased(MouseEvent e) {    }
    public void mouseEntered(MouseEvent e) { }
    public void mouseExited(MouseEvent e) {  }
    to make this program work? why when i declate 1 time this program doesn't work good?
    import java.awt.*;*
    import javax.swing.;
    import java.awt.datatransfer.*;
    import java.io.FileReader;
    import java.io.IOException;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseEvent;
    public class Main extends JPanel implements MouseListener {
    public Main() {
    super(new GridLayout(2,2));
    final JTextArea jt= new JTextArea("dear test :) ",5,20);
    FileReader reader = null;
    System.err.println("Error closing reader");
    exception.printStackTrace();
    JButton bu = new JButton("copiar");
    final Clipboard clipboard = getToolkit().getSystemClipboard();
    //new add
    add(nn);
    add(tt);
    bu.addMouseListener(new MouseListener() {
    public void mouseEntered(MouseEvent e) {
    StringSelection data = new StringSelection(jt.getText());
    clipboard.setContents(data, data);
    public void mouseClicked(MouseEvent e) {
    public void mousePressed(MouseEvent e) {
    public void mouseReleased(MouseEvent e) {
    public void mouseExited(MouseEvent e) {
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("TextDemo");
    public static void main(String[] args) {
    //Schedule a job for the event dispatch thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    public void mouseClicked(MouseEvent e) {    }
    public void mousePressed(MouseEvent e) {    }
    public void mouseReleased(MouseEvent e) {    }
    public void mouseEntered(MouseEvent e) { }
    public void mouseExited(MouseEvent e) {  }
    }

    import java.awt.;
    import javax.swing.;
    import java.awt.datatransfer.*;
    import java.io.FileReader;
    import java.io.IOException;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseEvent;
    public class Main extends JPanel implements MouseListener {
    public Main() {
    super(new GridLayout(2,2));
    final JTextArea jt= new JTextArea("dear test :) ",5,20);
    FileReader reader = null;
    System.err.println("Error closing reader");
    exception.printStackTrace();
    JButton bu = new JButton("copiar");
    final Clipboard clipboard = getToolkit().getSystemClipboard();
    //new add
    add(nn);
    add(tt);
    bu.addMouseListener(new MouseListener() {
    public void mouseEntered(MouseEvent e) {
    StringSelection data = new StringSelection(jt.getText());
    clipboard.setContents(data, data);
    public void mouseClicked(MouseEvent e) { }
    public void mousePressed(MouseEvent e) { }
    public void mouseReleased(MouseEvent e) {}
    public void mouseExited(MouseEvent e) { }
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("TextDemo");
    public static void main(String[] args) {
    //Schedule a job for the event dispatch thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    public void mouseClicked(MouseEvent e) { }
    public void mousePressed(MouseEvent e) { }
    public void mouseReleased(MouseEvent e) { }
    public void mouseEntered(MouseEvent e) { }
    public void mouseExited(MouseEvent e) { }
    } the problem is this line bu.addMouseListener(new MouseListener() {
    if i change this to bu.addMouseListener(this() {
    it gives error saying expected ')'
    and then doesn't compile.
    i just don't know why , although the program runs when i declare the methods two times,
    but i think it's better java code , if i learn it why is this error and correct it

  • Need countdown timer for game

    i'm making a shooting game i need a timer that counts down
    and then when it gets to 0 it goes to a certain frame. This is the
    code i'm using:
    var seconds:Number=10;
    time_txt.text="";
    function countDown(){
    var time=seconds--;
    time_txt.text=time;
    if(time=0){
    gotoAndStop("lose");
    clearInterval(counter);
    counter=setInterval(countDown, 1000);
    can any one help

    just in case this might help anyone tries to help
    here is the code i'm using for the game:
    stop();
    //Set global highScore variables
    highScore = 0;
    //Set the properties for the game elements
    _root.lastframe = false;
    //Stop bullets
    //See AS for bullet MC for details
    setProperty(_root.crosshair, _visible, true);
    setProperty(_root.bullet, _visible, false);
    //Individual destroyed target images hidden until needed
    setProperty(_root.target1d, _visible, false);
    setProperty(_root.target2d, _visible, false);
    setProperty(_root.target3d, _visible, false);
    //As above. Individual highlighted target images hidden until
    needed
    setProperty(_root.target1Image, _visible, false);
    setProperty(_root.target2Image, _visible, false);
    setProperty(_root.target3Image, _visible, false);
    mouse.hide();
    //hide mouse to use cross-hairs
    //select a target to shoot at random then add that target
    //to the array of selected targets so that it isn't used
    //again in this game.
    //When the number of direct hits against the selected
    //target has been reached. Find another random target.
    //Check whether it exists in the array. If yes, select
    //again. If no, make visible.
    _root.targets = new Array();
    //create array on the main
    //timeline so that it is
    //easily accessed by all MCs
    _root.targets[0] = "target1";
    _root.targets[1] = "target2";
    _root.targets[2] = "target3";
    //3 targets we are using in
    //tutorial
    n = _root.targets.length;
    //get length of array
    ran = random(n);
    //get random number location to select from array
    target = _root.targets[ran];
    //show random array location
    _root.activeTarget = target;
    //create target variable
    setProperty("_root."+target+"Image", _visible, true);
    //show target
    _root.targets.splice(ran, 1);
    //remove the random element
    //from the array. splice
    //the random number found and
    //to the depth of one so only
    //one element is removed.
    var seconds:Number = 10;
    time_txt.text = "";
    function countDown() {
    var time = seconds--;
    time_txt.text = time;
    if (time == -10) {
    gotoAndStop("lose");
    clearInterval(counter);
    counter = setInterval(countDown, 1000);
    any help will be appreciated
    Spud

  • An onsceen timer for game???

    Hi,
    I have to make a computer game in java3d and I'm pretty clueless, any help I could get here would be great.
    Current problem : Once the user presses a "Start" button I want a timer counting down from 5 mins. I want to timer to be on screen so the user can see it the whole time he is playing the game and when the timer is up a message appears ie GAME OVER! and the game stops running.
    Does anyone have any ideas or have done this before?? Heres some code on it I've hacked together so far.
    Thanks,
    Sean
    //create start button to start game/timer
    private Buttton go = new Button("Start");
    Panel p = new Panel( );
    p.add(go);
    add("North",p);
    go.addActionListener(this);
    go.addKeyListener(this);
    public void actionPerformed(ActionEvent e ) {
    // start timer when button is pressed
    if (e.getSource()==go){
    //if (time timer is not running) ???
    { //start timer +display timer ???
    //when timer == 0.00 add "game over" message to screen + stop game ???

    That's how you would do it in Java2D, for sure.
    If you want to put some Java2D stuff around your canvas, this kind of thing should work fine.
    If you want to incorporate it into your 3d scene (the way most games work) you will need to find a way to write it into your Java3D scene. There are a few different ways of doing this- I have had some success by writing the text into a graphic and then using the graphic I have just created as a texture on a plane attached to my viewPlatform. I believe there is something clever you can do to write it directly onto the view instead of using geometry in the scene, but I don't recall what...

  • Api for games programming

    What apis should i get to code nice games to mobile devices like cell phones?
    thanks
    bill

    hi there ..
    of course u can use midp1.0 or the new midp2.0
    with more cpabilities refer to the documentation
    to get more info..
    regardes
    Sola

  • Should I use Standard C++ Containers and Stuff for games and other real time activities?

    Hello,
    I'm a C++ developer using VS 2012 and VS 2010 for developing AAA titles. I have read about not using STL and other stuff provided in the standard headers that come with VS. I read most of the stuff on the websites based on game programming and some
    are really from the people well known in the industry. I have seen cases where they wont even use vector, list, map and others and not even use utility functions and algorithms. In such cases they write those containers and stuff themselves which has almost
    the same interface and so much of debug and implementation time spent on such huge code.
    I have two questions:
    1: Isn't the C++ implementation that comes with VS optimized for the platform for better performance? Isn't it using some intrinsic functions that people on the client end doesn't know about and supplying their own implementation would indeed be
    more slower in basic container operations such as insert, remove, find, swap, copy? Lets assume that we supply our own custom allocators for faster memory management to every container that we use. Also, they take care of fragmentation, alignment and stuff.
    Why develop custom containers with almost same interface, why not spend that time on writing allocators and other stuff that might actually help?
    2: There are times when we include a lot, a lot, of unnecessary stuff through the standard headers in a huge code base. Unnecessary, because we only needed a thing or two from such huge headers including other huge headers and so on. Now, I know templates
    aren't instantiated unless used, same goes for the members functions inside them and blah blah. Since, these are precompiled headers, it is safe to assume that there is no compile time hit for that unnecessary stuff. My question is, is there any hidden effect
    of such inclusions on code size (executable) that grows with the huge growth of the code base? In my opinion there shouldn't be, but I wanna know I'm not mistaken just in case. 

    Hi
    I can tell you a story about one of our projects. We had to implement a block management system for harddisks (like the parts of file systems that allocate, free blocks and do the bookkeeping stuff). Now, one guy was convinced, that we should use the STL,
    because it's easy to use and very well optimized and things like that. An other one said, that he would implement it by hand. So we decided to do both for a little test. The result was, that the hand implemented thing was much easier to write and much faster...
    and the one using STL saw, that some classes were so slow, that he couldn't believe it... he then tryed to build some classes by hand and exchange them (e.g. array classes and stuff like that) and it was way faster than the STL and he wrote them in minutes
    (!)... since then nobody wanted to use STL again... we don't even try it. It ended that we wrote our own string and array classes and stuff like that... easy little things that we understand. Now it's easy to use and fast and still flexible, because we know
    what it's doing...
    ... but, that's just a story about our development and of course, we're often programming very close to the hardware and also using assembler languages often... so, I don't know what this tells us... you have to decide :-)
    Rudolf

  • I recently downloaded a 10.6.8 update and a game program has now been reduced in size.  It's specifications are set for full screen, but it is about 1/4 of the size.  Any ideas how to fix?

    I recently downloaded a 10.6.8 update and a game program has now been reduced in size.  It's specifications are set for full screen, but it is about 1/4 of the size.  Any ideas how to fix?

    Hi, I have got the same problem but all is 1/4 the size have you fixed it?

  • Program SAPLSBAL_DB taking long time for BALHDR table entries

    Hi Guys,
    I am running a Z program in Quality and Production system both which is uploading data from Desktop.
    In Quality system the Z program is successfully uploading datas but in production system its taking very long time even sometime getting time out.
    As per trace analysis, Program SAPLSBAL_DB taking long time for BALHDR table entries.
    Can anybody provide me any suggestion.
    Regards,
    Shyamal.

    These are QA screen shots where no issue, but we are getting very long time in CRP.
    Regards,
    Shyamal

  • I have a problem with elements 8. When ever I start a new project, the program searches for the old, latest used filmmaterial, I have used before. That means, if I use a different DVD, it take so much time, until the program starts. So how can I stopp the

    I have a problem with elements 8. When ever I start a new project, the program searches for the old, latest used filmmaterial, I have used before. That means, if I use a different DVD, it take so much time, until the program starts. So how can I stopp the automatically uploading of old material?
    Thanks

    You have 2 unreachable statements in this method.
    public static int eval(String s2, String op, String s3) {
    return lookup(s2);
    return lookup(op);
    return lookup(s3);
    } You're missing a } at the end of this method:
    public static int lookup(String s) {
        for(int k = 0; k < symbols.length; k++){
            String symbol = symbols[k];
            if(s.equals(symbol))
                return k;
        }You have some loose } and ; at the end of the file:
    public static void main(String args[])
    commandline();
    }

Maybe you are looking for