Login | Register | FAQ
Anonymous

(Help needed ) HTML 5 and Java development

+ Post a reply

2 posts Page 1 of 1


(Help needed ) HTML 5 and Java development

by MutatedMonk » Sat Nov 05, 2016 2:59 am

Hi guys, first time posting on here.

I was wondering if anyone could help me out, I am creating a Break Out game, now i have experience with HTML and CSS but i'm hopeless when it comes to Java. The code below is what i have so far, now what i want to do is create two different levels, one that is just a rectangle of rectangles and another that is a sphere.

This is my code.

---------------------------------------------------------------
<html>
<head>



<link rel="stylesheet" type="text/css" href="styles/main.css" />
<link rel="shortcut icon" type="image/png" href="pics/favcon.png">
<title>Javascript Game</title>
</head>
<body>
<div id="body">


<center>
<canvas


style= "border:3px solid #CD7F32; background-color: #52503C;"
id = "mycanvas"
width = "900"
height = "900">


Your browser does not support canvas
</canvas>
</center>


<script>
window.addEventListener("load", myApp, false);
function myApp() {

var canvas;
var context;
var textToShow;
var x;
var y;
var rad;
var col;
var ydir;
var loops;
var offset;


function getCanvas() {
var tmp;

tmp = document.getElementById ("mycanvas");

if (tmp == null) {
alert ("no canvas");
}

return tmp;

}


function animateMe() {
var counter;
var counter2;
context.clearRect (0, 0, canvas.width, canvas.height);

x = 10;
y = 10;
rad = 10;
col = "blue";

for (counter = 0; counter < 8; counter++) {
for (counter2 = 0; counter2 < 8 ; counter2++) {

if ((counter2 + counter) % 2 == 0) {
context.fillStyle = "white";
}
else {
context.fillStyle = "black";

}
context.fillRect (x, y, 49, 49);


x = x + 50;

}

y += 50;
x = 10;

}



context.clearRect (0, 0, canvas.width, canvas.height);



requestAnimationFrame (animateMe);
}

canvas = getCanvas();

context = canvas.getContext ("2d");


init();


function init() {
x = 50;
y = 50;
rad = 10;
col = "blue";
ydir = 1;
offset = 0;
animateMe();
}

}

</script>
</div>
</body>

</html>
---------------------------------------------------------------

Thank you for any help in advance.
User avatar

MutatedMonk

  • Posts: 1
  • Joined: Sat Nov 05, 2016 2:50 am

Re: (Help needed ) HTML 5 and Java development

by nanoverso » Thu Nov 10, 2016 12:45 am

The programming language for HTML 5 you need to learn for this task is called Javascript, Java itself is another language.
User avatar

nanoverso

  • Posts: 248
  • Joined: Sat May 10, 2014 12:08 am
  • Location: Brazil
--
Mario blog (Portuguese): http://jogos-do-mario.nanoverso.com


+ Post a reply

Page 1 of 1