Topic:   HTML5GM Newbie Questions Thread 1   (Read 14361 times)


0 Members and 1 Guest are viewing this topic.

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
HTML5GM Newbie Questions Thread 1
« on: February 03, 2012, 11:12:24 PM »
Okay, repeatedly calling ClearScreen() causes sprites to flicker, if they are drawn on a separate timer. Is there a better way to prevent them from leaving trails? And would I be able to draw a background?
But probably a more important matter is that I'm trying to use push to add objects to an array and they keep overwriting the same object. I thought that added spaces. ???
« Last Edit: February 03, 2012, 11:14:50 PM by Connors »
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: HTML5GM Newbie Questions Thread 1
« Reply #1 on: February 03, 2012, 11:48:44 PM »
Yeah, timers don't always sync so if you're drawing with certain timers and calling ClearScreen on another timer, sometimes the sprites will draw before the screen is cleared and sometimes after the screen is cleared. Hence the flickering.

To fix this I'd suggest have all drawing done on the same timer.

As for your array issue, that is quite strange. myArray.push(myObject) should add the object to the end of the array. You can check the array's length by alert(myArray.length).

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: HTML5GM Newbie Questions Thread 1
« Reply #2 on: February 03, 2012, 11:58:21 PM »
There's also a bug when you create your UFOs:
Code: [Select]
ships.push(ufo())
That should be:
Code: [Select]
ships.push(new ufo())

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: HTML5GM Newbie Questions Thread 1
« Reply #3 on: February 04, 2012, 12:05:12 AM »
Also this:
Code: [Select]
this.x = 620
this.y = Random(5,145)
this.timer = new Timer("move()", 1/30)

You are creating a timer within the object, trying to point to a method of the object.
I haven't actually figured out how to make timers work on object methods, so that timer is actually looking for the global move() method, which there is none.
Yeah... It'd probably be best to have a single timer for movement and a single timer for drawing. Or a single timer for both.

Zoo


  • GMG Extraordinaire

  • ***


  • Posts: 1686
    • My Bandcamp
Re: HTML5GM Newbie Questions Thread 1
« Reply #4 on: February 26, 2012, 08:17:11 AM »
Aww... I thought this was a game. It had it listed as "Html5GM newbie quest..."
lol
Kirby, your pudgy buddy from dream land, is back again on the game boy®!

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: HTML5GM Newbie Questions Thread 1
« Reply #5 on: February 26, 2012, 10:29:57 AM »
Hahah, that's an awesome game title.

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: HTML5GM Newbie Questions Thread 1
« Reply #6 on: February 27, 2012, 12:05:21 PM »
What about "Square Dude's Adventures in Generic Platformer World"?
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Finally, a more interesting question...
« Reply #7 on: March 08, 2012, 11:59:53 PM »
I know you can set a timer's speed, which is great and all, but it still slows down when the game lags. I want to know if I can have precise timing based on checking a number of ticks. I assume you could do this with GetMilliseconds().
Now, I remember a function in TNT that checks exactly how long a sound such as a song has been playing. You can check where the song is at any time, even if the song itself lags at all. Can this be done in GM5? I'm curious because the idea of a music game is neat and I might want to attempt it again, despite how tricky it was.
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: HTML5GM Newbie Questions Thread 1
« Reply #8 on: March 10, 2012, 04:29:03 PM »
http://gamemakersgarage.com/html5/HTML5-ShareGame.php?gameID=249
This game will not run. I am not happy. :/
EDIT: Everything runs now. I have found that the pixel canvas will replace anything drawn on screen. If it is transparent, then you see whatever is on the page behind the game. I had hoped pixels would allow you to see what was drawn behind them based on Alpha, because you could make some SWEET and also FAST in-game effects. But, they seem to ruin everything.
EDIT #2: DrawPixel is the same way.
« Last Edit: March 10, 2012, 05:46:41 PM by Connors »
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: HTML5GM Newbie Questions Thread 1
« Reply #9 on: March 10, 2012, 06:01:34 PM »
That's unfortunate.

I believe I have a solution to this problem. Layers.
I've been researching into canvas layers. Where your game starts with the main layer, then you can add layers to it. Each layer is it's own canvas.

So if there were layers, you'd draw the background once on the main layer, then you'd create a new layer and you'd constantly redraw the lighting on the new layer.
Layers are transparent so it's most likely work perfectly.
And because you only need to draw the background image once, there would be a significant speed boost.

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: HTML5GM Newbie Questions Thread 1
« Reply #10 on: March 10, 2012, 06:08:39 PM »
Sound great! Also sounds like a probable solution to the Space Marine tile map problem. I'd love to see where this goes.
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

Circuit


  • GMG-er

  • **


  • Posts: 299

  • blast from the past
Re: HTML5GM Newbie Questions Thread 1
« Reply #11 on: March 15, 2012, 04:09:18 AM »
This is more of a request than a question.  Gan, I was working on a project today when I discovered that For loop counters can't be decremented.  "For x = 1 to 5" will execute, but "For x = 5 to 1" won't.  Would you fix that, please?  I'm about halfway done with a math algorithm that solves matrices.  I need to be able to count backwards to do the second half of it.
« Last Edit: March 15, 2012, 04:37:40 AM by Circuit »

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: HTML5GM Newbie Questions Thread 1
« Reply #12 on: March 15, 2012, 10:29:48 AM »
Of course the obvious workaround is a simple while loop with x -= 5 at the end.
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: HTML5GM Newbie Questions Thread 1
« Reply #13 on: March 15, 2012, 11:28:51 AM »
True, I want to make this as friendly as possible though.

Customizing a for loop will require a few extra keywords.
You guys fine with this?
Code: [Select]
For x = (some num) to (some num) decreasing by (some num)
The extra keywords are optional.
Yours would look like:
Code: [Select]
For x = 5 to 1 decreasing by 1
Similarly, you could do:
Code: [Select]
For x = 5 to 1 decreasing by 2
Or:
Code: [Select]
For x = 1 to 10000 increasing by 100
And the normal statement would still work perfectly:
Code: [Select]
For x = 1 to 5

The reason I can't make it automatically check if it's decreasing is because someone could make this type of for loop:
Code: [Select]
For x = y to z*3-18
At compile time, I can't determine the values of variables.

Circuit


  • GMG-er

  • **


  • Posts: 299

  • blast from the past
Re: HTML5GM Newbie Questions Thread 1
« Reply #14 on: March 15, 2012, 04:05:49 PM »
The reason I can't make it automatically check if it's decreasing is because someone could make this type of for loop:
Code: [Select]
For x = y to z*3-18
At compile time, I can't determine the values of variables.
Ahh.  I was wondering why it couldn't be done automatically.  That makes sense.

Customizing a for loop will require a few extra keywords.
You guys fine with this?
Code: [Select]
For x = (some num) to (some num) decreasing by (some num)
...
That's fine, but I think that "add" and "subtract" would be better than "increasing" and "decreasing".  The latter pair can easily be misread and confused because they're so similar.
« Last Edit: March 15, 2012, 04:21:52 PM by Circuit »