So basically I want to make an object appear on a simple HTML canvas through the class GameObject
and I can’t get it done. The code compiles fine but it just doesn’t appear on the screen. I assume it has to do with the variable ctx
but I’m not too sure.
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
square = new GameObject(20, 40, 50, 50, "blue");
square.drawObject();
class GameObject {
constructor(x, y, w, h, color) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.color = color;
}
drawObject() {
ctx.rect(this.x, this.y, this.w, this.h);
ctx.fillStyle = this.color;
ctx.fill();
}
}
<style>
* { padding: 0; margin: 0; }
canvas { background: #eee; display: block; margin: 0 auto; }
</style>
<canvas id="myCanvas" width="480" height="320"></canvas>
2.5 mg cialis daily – canadian pharmacy tadalafil order cialis without prescription
ivermectin pills canada – stromectol uk buy stromectol 3 mg
play for real online casino games – casino games win real money online casino gambling
ed treatments that work immediately – treatment for ed cure ed
buying cialis – Pharmacy cialis tadalafil 5mg coupon
stromectol cream – cost of stromectol ivermectin 0.2mg
ed pills – best ed pill gas station ed pills
doxycycline 60 mg – doxycycline medicine in india 2985 doxycycline
where to buy prednisone 20mg no prescription – order prednisone without prescription prednisone over the counter uk
doxycycline 100 mg cost generic – buy doxycycline without rx buy prednisolone tablets
hydroxychloroquine zinc azithromycin – prednisone 10 mg tablets prices for prednisone
orlistat max dose – orlistat cost xenical nih
buy ivermectin usa – topical stromectol cost buy stromectol for humans
585136 226262educator, Sue. Although Sue had a list of discharge instructions in her hand, she paused and 53387
ivermectin – stromectol buy australia ivermectin topical
395528 448277I gotta bookmark this website it seems really useful . 906549
generic prednisone 20mg – prednisone 10mg for sale buy prednisone 20mg online
prednisone cost in india – prednisone prescription prednisone without prescription medication
price of zithromax – buy azithromycin 250mg azithromycin 500mg for sale
order priligy 60mg – priligy sale cheap prednisolone generic
order viagra 150mg generic – purchase viagra generic cialis 40mg cost
sildenafil 25mg generique pas cher – viagra 200mg gГ©nГ©rique cialis 20mg generique en pharmacie
tadalafil without a doctor prescription buy cialis
buy prednisone 20mg online – canadian pharcharmy prednisone 40mg pills
https://cialistrxy.com/ tadalafil side effects
hydroxyzine 10mg ca – domperidone price purchase rosuvastatin sale
cialis cost where to buy cialis without prescription
canada generic tadalafil tadalafil cost walmart
where to order tadalafil tablets where to buy tadalafil on line
buy inderal pills – inderal 20mg price order hydroxychloroquine generic
buy generic aralen – chloroquine ca viagra 100mg for sale
https://cialisedot.com/ where to buy tadalafil on line
buy generic cialis online with mastercard tadalafil drug
343561 335933Some truly quality weblog posts on this internet internet site , saved to my bookmarks . 510957
ivermectin tablets for sale buy 12mg ivermectin
generic stromectol 12 mg ivermectin generic
generic ivermectin 12 mg https://www.ivermectinoge.com/