Jump to content
Sign in to follow this  
acosmist

logic error preventing sprites from appearing in canvas game I am creating

Recommended Posts

I seem to have gotten in over my head with this project. I spent most of the day just typing out code, without the ability to debug it due to slow browser speed. When I got off work I started correcting my syntax errors, which didn't take very long. Unfortunately, I have spent many hours trying to resolve some sort of logic error in the game which is apparently a very serious one, as it prevents any of my sprites from appearing. The fillRect() function is showing up perfectly, but the drawImage() function is not. I will go ahead and post the whole game code, as it is pretty concise by my own meager standards. I am a noob to javascript and coding in general, and this will probably show. That being said, I really expected this to work, and would certainly appreciate any help which is on offer. Upon previewing my post I noticed that spacing differences rendered my map array unreadable. I have decided to attach a text file (as I am not permitted to upload .js files) instead of pasting. I hope this is acceptable. script.txt

Share this post


Link to post
Share on other sites

I just corrected a small bug, but it didn't solve the problem. On lines 48 and 49 I typed "img.x" and "img.y" instead of "imgX" and "imgY". I had also defined sprites[0].img as an object.

Share this post


Link to post
Share on other sites

Do you have this online anywhere to look at? Have you been checking your browser's error console for messages?

Share this post


Link to post
Share on other sites

I will put it online sometime today for you. The reason I am assuming it is a logical error and not a syntax error is because I am not receiving any error messages at this time in firebug or the google chrome javascript console.

Share this post


Link to post
Share on other sites

Well, I put it online, but after reading through the forum rules I am not so sure I should post the address. It is one of those "free domain names". Also, I have resolved the bug in question, having gotten the sprites to display. Remember kids, when making multiple canvas elements for a video game, set your inline style position to 'absolute;left:0;top:0;'

Share this post


Link to post
Share on other sites
I seem to have gotten in over my head with this project. I spent most of the day just typing out code, without the ability to debug it due to slow browser speed. When I got off work I started correcting my syntax errors...
This looks pretty complicated. Are you basing this code on some other example?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...