Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oblerion/love2d.js
love2d framework for javascript game. without emscripten.
https://github.com/oblerion/love2d.js
framework game-development html5 javascript love2d opensource
Last synced: 4 days ago
JSON representation
love2d framework for javascript game. without emscripten.
- Host: GitHub
- URL: https://github.com/oblerion/love2d.js
- Owner: oblerion
- License: mit
- Created: 2021-06-04T11:16:36.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-31T15:50:23.000Z (6 months ago)
- Last Synced: 2024-06-01T16:56:34.148Z (6 months ago)
- Topics: framework, game-development, html5, javascript, love2d, opensource
- Language: JavaScript
- Homepage:
- Size: 706 KB
- Stars: 12
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [love2d.js](https://github.com/oblerion/love2d.js)
## Table of content
- [Description](#Description)
- [Features](#Features)
- [Example](#Example)## Description
[love2d](https://love2d.org) api for html5 game, not using emscripten, made with equivalent of lua functions written in javascript## Features
- draw : text, rectangle, cercle , line
- load image, song ,video and use it
- input : keyboard, mouse and touch
- setting window and icon
see [manual](https://github.com/oblerion/love2d.js/blob/main/love2djs_manual_en.pdf) for more info
## Example
a simple index.html
```htmlsimple test
// if no support for module
document.write("your old browser don't support module type : need update it");
import love from "./love2d.js";player = {x:10,y:100};
// loading function
love.load=function()
{
// set width and height screen of game
love.window_setMode(1000,500);
// set font
love.graphics_setFont("arial");
// load image
pic= love.graphics_newImage("test.png");
q = love.graphics_newQuad(0,0,16,16);
// set icone
love.window_setIcon(pic);
// loading loop song
song = love.audio_newSource("test.wav","stream");
love.audio_setVolume(0.2);
//video loading
vid = love.graphics_newVideo("test.webm");
// start video
vid.play();
}
// update loop function
love.update=function(dt)
{
if(love.keyboard_isDown("left"))
{
player.x -= 20*dt;
love.audio_play(song);
}
if(love.keyboard_isDown("right"))
{
player.x += 20*dt;
love.audio_stop(song);
}
//print(player.x,player.y);
}
// draw loop function
love.draw =function()
{
let Mx = love.mouse_getX();
let My = love.mouse_getY();
love.graphics_print("left for start music right for stop",12,34,"blue",25);
love.graphics_setColor(200,2,2,125);
love.graphics_print("hello ",200,250,0,25);
love.graphics_setColor(0,200,0,125);
love.graphics_draw(pic,player.x,player.y,0,64,64);
love.graphics_setColor(200,2,2);
love.graphics_line(Mx,0,300,34);
love.graphics_draw(pic,150,50,0,64,64);
love.graphics_draw(vid,23,23);
}
```
## It use love2d.js
[magnus oblerion website](https://oblerion.github.io/website/)