//thanks to GameAlchemist
    function createCountDown(timeRemaining) {
        var startTime = Date.now();
        return function() {
        return timeRemaining - ( Date.now() - startTime );
        }
    }
    var currentCountDown = createCountDown(30000);
    // Draw everything
    var render = function () {
    var countDownValue = currentCountDown();
    returnKillsNeeded(stageNum);
        ctx.drawImage(startGameImg, 0,0);
        ctx.font = "24px Helvetica";
        ctx.textAlign = 'center'
        ctx.textBaseline = "top";
        ctx.fillStyle="#FF0000";
        ctx.fillText("press Enter to play", 250, 450);
        ctx.fill();
        if(gameStart){
    if (bgReady) {
    ctx.drawImage(bgImage, 0, 0);
    }
    ctx.fillStyle="#522900";
    ctx.fillRect(0,480,500,120);
    ctx.drawImage(scoreImg, 22,522);
    ctx.drawImage(livesImg, 360,522);
    ctx.drawImage(progressImg, 200,492);
    createProgressBar();
    createProgressPercent();
    ctx.fillText("progress", 170,492);
    setEnemyHealthText();
    drawPlayer();
    if(countDownValue <=0){
        countDownValue = 0;
    }else{
        ctx.fillText(countDownValue, 200,190);
    }
rproffitt commented: You did it again. Dump code and not much else. -2

Converting from say seconds in some variable to minutes and seconds is a classic beginner's programming exercise.

Think about how you do this in your head now. Now some can translate that directly to code but for beginners you may have them write down the process step by step. You have them do this since they won't learn by you giving them the code. Again you never give them the code.

Why? It's so they learn how to break down the problem to discrete steps that you can write code from. If the step can't be translated into code you help them along by telling them to break that step down into smaller steps.

I'm still beginner. I still learn si I ask you to help me

rproffitt did help you. (S)he gave you excellent advice. `"Think about how you do this in your head now. Now ... translate that directly to code. If the step can't be translated into code ... break that step down into smaller steps".

If you can't describe how to do it in your head or on paper then you can't begin to write any relevant code.

I'm still beginner. I still learn si I ask you to help me

OP, that doesn't work. I too am a "beginner" at whatever language you are using since I don't know what the language is (it doesn't get much more "beginner" than that, does it? :)) So why am I commenting on this thread? What possible contribution could someone who is so unfamiliar with this language make? I'm gonna just guess "Javascript". But again, that's just a guess.

First, I checked out this thread because I didn't know what language it was. You didn't tag it with "javascript" or whatever. If you had, I would have ignored the thread.

Second, I counted the number of opening brackets and closing brackets in your code and... they don't match. Apologies for a possibly bad assumption, but in every language I've bumped into, they have to match. Assuming they have to match in this language too, well you didn't even bother to paste code where the number of brackets match, nor did you point that fact out, nor did you make an attempt to tell people where you THINK the problem is, what the function that is SUPPOSED to do what you are stuck on is doing, etc. etc. You can do all this as a complete beginner.

Now let's say I was a beginner in C++. How would a BAD post look that was trying to do about what you are trying to do? Read on...

can u plz fix my code thanx
using namespace std;

int main()
{
    int seconds = 500;
    ChangeToMinutesAndSeconds(500);
    cout << minutes << " " << seconds <<endl;
    return 0;
}


int ChangeToMinutesAndSeconds(int minutes, int seconds)
{
    minutes = seconds / 60;
    seconds %= 60;
}

Now it's extremely obvious to any C++ programmer what the problems are in this code. We don't really need to compile it. But the post mentions nothing about errors, leading us to wonder if the person even bothered to compile it. The person gives no indication that it's THEIR code. They give no indication of their experience level and where they're stuck. We have to play twenty questions with them. Plus the poor English sentence. Capitalization, spelling, punctuation, it all counts. No, this isn't an English class. If English isn't your first language and you screw up a little, that's fine, but try to make an effort at it so we know you're a serious adult.

Now for a GOOD post. Read on...

Hi, I am taking my first semester of C++ Programming at my university. We just finished learning about functions and how to use local variables instead of global variables. I know how to pass by value, but not pass by reference. My code is below. I believe the error is on line 10. Errors are... (list of errors)

That is a good description. We can compare the expected expertise level of the code with the description. Someone who wrote this description and posted the code above is making errors that he shouldn't make (i.e. errors not having to do with pass-by-reference), so we'd point them out, tell them to fix it, but not tell them how too much because they are already supposed to know. When they followed up with better code with only errors having to do with pass-by-reference, well there's that "effort" thing, and we'd compose a slightly LONGER answer involving fixing the pass-by-reference errors.

So, all in all, beginner or not, you can do WAY better than you're doing with these posts. I don't care if you're a beginner. Again, I'm a beginner in whatever language you're using and there's NO WAY I would ever post a thread the way you did. I would make it extremely obvious that I was making an effort. It's not difficult, so do it. When I was tutoring, I would have kicked you out of my office for lack of effort. On this forum, I'll simply not help. If you're serious about learning, you'll improve. If you continue to post in this manner, we'll all know beyond any doubt that you're not willing to put in any effort.

Read this link. It should be a sticky on all forums everywhere.

http://catb.org/~esr/faqs/smart-questions.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.