Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8819299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:19:20+00:00 2026-06-14T05:19:20+00:00

I’m working on a very small project in JavaScript just to help me understand

  • 0

I’m working on a very small project in JavaScript just to help me understand the canvas from the bottom up. I’m trying to avoid using frameworks and the like for now, just so I can understand the basic functionality of HTML5 games.

It’s a fairly basic “cursor mover” with a fading tail. That’s it. Just a shape in one color, moving around based on player input, with a fading tail. I suggest you try it out; it’s actually quite pretty.

Anyways, obviously I’d prefer the cursor to be a circle because it looks smoother. However, whenever I do so, the browser pretty much completely locks up on me. It clearly works, at least to a good extent, but it’s slower than a turtle running through frozen peanut butter.

I know I’m not supposed to include just JSFiddle, but it’s kind of a lot of code and the whole thing is running slowly.

The problem is most likely in the draw function:

Game.draw = function() {
    for (var sn = 0; sn < this.strokes.length; sn++) {
        var s = this.strokes[sn];
/*1*/   this.context.arc(s.x, s.y, this.cursorRadius, 0, 2 * Math.PI);
        this.context.fillStyle = this.bgColor;
/*2*/   //this.context.fillRect(s.x, s.y, this.cursorWidth, this.cursorHeight);
/*1*/   //this.context.fill();
        this.context.fillStyle = s.getColor();
/*2*/   //this.context.fillRect(s.x, s.y, this.cursorWidth, this.cursorHeight);
/*1*/   this.context.fill();
    }
};

The lines are labeled by approaches. 1 corresponds to circles, while 2 corresponds to rectangles.

Here’s the whole project: http://jsfiddle.net/w4Rg3/3/

I just find it kind of hard to believe that it’s so incredibly much slower to have circles (after seeing all of the projects that JS can do), and that I might be doing something wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:19:22+00:00Added an answer on June 14, 2026 at 5:19 am

    everyone! I found the issue! It has nothing to do with the structure of my game or anything particularly finicky. Just an API issue!

    The problem is indeed in the code sample in my question in the first post.

    Game.draw = function() {
        for (var sn = 0; sn < this.strokes.length; sn++) {
            var s = this.strokes[sn];
    /*1*/   this.context.beginPath();  /*THIS IS FIXED*/
    /*1*/   this.context.arc(s.x, s.y, this.cursorRadius, 0, 2 * Math.PI);
    /*1*/   this.context.closePath();  /*THIS IS FIXED*/
            this.context.fillStyle = this.bgColor;
    /*2*/   //this.context.fillRect(s.x, s.y, this.cursorWidth, this.cursorHeight);
    /*1*/   this.context.fill();
            this.context.fillStyle = s.getColor();
    /*2*/   //this.context.fillRect(s.x, s.y, this.cursorWidth, this.cursorHeight);
    /*1*/   this.context.fill();
        }
    };
    

    I made sure to mark the lines that I added with a “THIS IS FIXED” comment. I assume that it was previously just creating a really, really long arc and drawing it over and over, but who knows? Anyways, problem solved, and it looks beautiful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a small JavaScript validation script that validates inputs based on Regex. I
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.