Game Maker's Garage Forum

Game Maker's Garage => Trash Talk => Topic started by: Connors on January 25, 2012, 11:54:04 PM

Title: HTMLGM5 Forum Test 1
Post by: Connors on January 25, 2012, 11:54:04 PM
<script src='http://www.gamemakersgarage.com/html5/jquery.min.js'></script>
<script src='http://www.gamemakersgarage.com/html5/HTML5-Commands.js'></script>
<div style='text-align:center;'>
<div style='width:100%;height:100%'>
<canvas id='gameCanvas' width='500px' height='500px' style='cursor:default;outline: none;border:1px solid;border-color:#949494;position:relative;margin:auto;top:10px;background:transparent;'></canvas>
</div>
</div><script type='text/javascript'>

var g1Count = 1;
var g1Forward = true;
var g2Count = 1;
var g2Forward = true;
var g3Count = 1;
var g3Forward = true;
function Game_Open() {

LoadImage("t1");
LoadImage("t2");
LoadImage("t3");

CreateTimer("Guy 1", "Guy1Dance()", 0.05);
CreateTimer("Guy 2", "Guy2Dance()", 0.1);
CreateTimer("Guy 3", "Guy3Dance()", 0.2);
CreateTimer("Draw Timer", "Draw()", 1/60);

SetFillColor("Pink");

PlaySound("Music","MyBackgroundMusic",true);
}
function Key_Down() {
}
function Key_Up() {
}
function Mouse_Down() {
}
function Mouse_Up() {
}
function Mouse_Move() {
}
function Game_Close() {
}
function Guy1Dance() {

if ( g1Forward ) {
g1Count += 1;
}
if ( !g1Forward ) {
g1Count -= 1;
}

if ( g1Count > 3 ) {
g1Count = 3;
g1Forward = false;
}
if ( g1Count < 1 ) {
g1Count = 1;
g1Forward = true;
}
}
function Guy2Dance() {

if ( g2Forward ) {
g2Count += 1;
}
if ( !g2Forward ) {
g2Count -= 1;
}

if ( g2Count > 3 ) {
g2Count = 3;
g2Forward = false;
}
if ( g2Count < 1 ) {
g2Count = 1;
g2Forward = true;
}
}
function Guy3Dance() {

if ( g3Forward ) {
g3Count += 1;
}
if ( !g3Forward ) {
g3Count -= 1;
}

if ( g3Count > 3 ) {
g3Count = 3;
g3Forward = false;
}
if ( g3Count < 1 ) {
g3Count = 1;
g3Forward = true;
}
}
function Draw() {

ClearScreen();

if ( Random(0,100) == 5 ) {

SetFillColor("rgba("+Random(0,250)+","+Random(0,250)+","+Random(0,250)+","+250+")");
}

FillRect(0,0,500,500);

DrawImage("t"+g1Count,150,200,0);
DrawImage("t"+g2Count,250,400,0);
DrawImage("t"+g3Count,350,200,0);
}
var canvas;
var imageArray = new Array();
imageArray["t1"]= "http://gamemakersgarage.com/html5/Demo%20Images/timerDemo1.png";
imageArray["t2"]= "http://gamemakersgarage.com/html5/Demo%20Images/timerDemo2.png";
imageArray["t3"]= "http://gamemakersgarage.com/html5/Demo%20Images/timerDemo3.png";
var soundArray = new Array()
soundArray["Music"]= "http://www.gamemakersgarage.com/html5/Demo Sounds/DanceDemo.mp3";
var context;
var mousePressed= false;
var lastKeyPressed = null;
var keyPressedArray = new Array();
for (i = 0; i < 300; i++) {keyPressedArray.push(false);}var mouseX = 0;
var mouseY = 0;
$('#gameCanvas').ready(function() {canvas = document.getElementById('gameCanvas');context = canvas.getContext('2d');prepareCommands();Game_Open();});
$('#gameCanvas').keydown(function(e){ lastKeyPressed = e.keyCode; keyPressedArray[lastKeyPressed] = true; Key_Down(); return false; });
$('#gameCanvas').keyup(function(e){ lastKeyPressed = e.keyCode; keyPressedArray[lastKeyPressed] = false; Key_Up(); return false; });
$('#gameCanvas').mousedown(function(e){ mouseX = getMousePos(canvas,e).x; mouseY = getMousePos(canvas,e).y; mousePressed = true; $(this).focus(); Mouse_Down(); return false; });
$(window).bind('mouseup',function(e){ mouseX = getMousePos(canvas,e).x; mouseY = getMousePos(canvas,e).y; mousePressed = false; Mouse_Up(); return false; });
$('#gameCanvas').mousemove(function(e){ mouseX = getMousePos(canvas,e).x; mouseY = getMousePos(canvas,e).y; Mouse_Move(); return false; });
$('#gameCanvas').attr('tabindex', '0');
jQuery('#gameCanvas').bind('beforeunload', function(){ Game_Close(); $(window).unbind('mouseup');})</script>
Title: Re: HTMLGM5 Forum Test 1
Post by: Gan on January 25, 2012, 11:54:26 PM
Nice try
Title: Re: HTMLGM5 Forum Test 1
Post by: Connors on January 25, 2012, 11:58:38 PM
Failsplosion.
 I kind of figured this would block people adding random javascript.
Well, so far this program is a success, the biggest limit is what the user can do.
Tomorrow I'll have more time to really get into a project... But if I do I think I'll try to relate it to my collision detection program I hate to keep starting new projects and leaving the rest sitting on my hard drive.
Heeeey I can use my free time at school, because it's all online. Unless I can't use Chrome. Dang it.
Title: Re: HTMLGM5 Forum Test 1
Post by: Gan on January 26, 2012, 12:25:17 AM
Heh. I'm going to work on multi-browser support. Start with Firefox, then the dreaded IE.
Title: Re: HTMLGM5 Forum Test 1
Post by: Zoo on January 26, 2012, 03:35:11 PM
You need to add a section where we can actually post things like this. Like an HTML5GM creations section where we can actually edit the HTML of the posts.
Title: Re: HTMLGM5 Forum Test 1
Post by: Gan on January 26, 2012, 04:31:49 PM
I've researched it and it seems to be too big of a security risk. Admins have the ability but there's no way to give normal users the ability to post HTML code.

The next best thing is just posting the actual link to the game in the post. One click and open.
Title: Re: HTMLGM5 Forum Test 1
Post by: Connors on January 26, 2012, 09:49:13 PM
And that will work JUST FINE. ;)
Title: Re: HTMLGM5 Forum Test 1
Post by: Charlo on January 27, 2012, 05:49:22 PM
Yeah, giving users the ability to post rendered HTML is not a good idea AT ALL.  Even though we're generally a well-behaved bunch.   :P