• Idées de mots clés pour obtenir 4 images réalistes : 3D, 4 images, realiste hd, 4k, pixar style.
    Par exemple : Génére moi 4 images de dinde dans une ferme en 3d 4k haute resolution avec le style pixar
    4 images par demande maximium.

et si on donnait à picafofo....

  • Auteur de la discussion ZZZ
  • Date de début
ZZZ
Passionné
Messages
1 400
Fofocoins
7 662
Personnalisation du groupe
Personnalisation pseudo
du code:

JavaScript:
const canvas = document.getElementById("canvas");
const context = canvas.getContext("2d");

function resizeCanvas() {
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
    canvas.width = document.body.clientWidth;
    canvas.height = document.body.clientHeight + 4;
}

window.addEventListener('resize', resizeCanvas);
resizeCanvas();

var keys = {};
window.addEventListener("keydown", function (event) {
    keys[event.keyCode] = true;
});

window.addEventListener("keyup", function (event) {
    delete keys[event.keyCode];
});

var player = {
    position: {
        x: null,
        y: null,
        init() {
            player.position.x = 0;
            player.position.y = 0;
            player.position.real.x = canvas.width / 2 - player.proportion.head.width / 2
            player.position.real.y = canvas.height / 2 - player.proportion.head.height / 2
        },
        real: {
            x: undefined,
            y: undefined
        }
    },
    proportion: {
        width: 65,
        height: 65,
        head: {
            width: 65,
            height: 65
        }
    },
    speed: {
        normal: -4.5,
        diagonal: -(4.5 / Math.sqrt(2)),
        right: true,
        left: true,
        up: true,
        down: true
    }
}

function createBlock(x, y, width, height, margin = 10) {
    if (keys[37]) {
        if (player.position.real.x - margin <= x + width &&
            player.position.real.x + player.proportion.head.width + margin >= x + width - player.speed.normal) {
            if (
                player.position.real.y >= y &&
                player.position.real.y <= y + height ||
                player.position.real.y + player.proportion.height >= y &&
                player.position.real.y + player.proportion.height <= y + height ||
                player.position.real.y <= y &&
                player.position.real.y + player.proportion.height >= y + height
            ) player.speed.left = false; else player.speed.left = true;
        } else player.speed.left = true;
    }
    if (keys[38]) {
        if (player.position.real.y - margin <= y + height &&
            player.position.real.y + player.proportion.head.height + margin >= y + height - player.speed.normal) {
            if (
                player.position.real.x >= x &&
                player.position.real.x <= x + width ||
                player.position.real.x + player.proportion.width >= x &&
                player.position.real.x + player.proportion.width <= x + width ||
                player.position.real.x <= x &&
                player.position.real.x + player.proportion.width >= x + width
            ) player.speed.up = false; else player.speed.up = true;
        } else player.speed.up = true;
    }
    if (keys[39]) {
        if (player.position.real.x + player.proportion.head.width + margin >= x &&
            player.position.real.x - margin <= x + player.speed.normal) {
            if (
                player.position.real.y >= y &&
                player.position.real.y <= y + height ||
                player.position.real.y + player.proportion.height >= y &&
                player.position.real.y + player.proportion.height <= y + height ||
                player.position.real.y <= y &&
                player.position.real.y + player.proportion.height >= y + height
            ) player.speed.right = false; else player.speed.right = true;
        } else player.speed.right = true;
    }
    if (keys[40]) {
        if (player.position.real.y + player.proportion.head.height + margin >= y &&
            player.position.real.y - margin <= y + player.speed.normal) {
            if (
                player.position.real.x >= x &&
                player.position.real.x <= x + width ||
                player.position.real.x + player.proportion.height >= x &&
                player.position.real.x + player.proportion.height <= x + width ||
                player.position.real.x <= x &&
                player.position.real.x + player.proportion.height >= x + width
            ) player.speed.down = false; else player.speed.down = true;
        } else player.speed.down = true;
    }
}

function update() {
    if (keys[38] && !keys[37] && !keys[39]) {
        if (player.speed.up) player.position.y += player.speed.normal;
    }
    if (keys[40] && !keys[37] && !keys[39]) {
        if (player.speed.down) player.position.y -= player.speed.normal;
    }
    if (keys[37] && !keys[38] && !keys[40]) {
        if (player.speed.left) player.position.x += player.speed.normal;
    }
    if (keys[39] && !keys[38] && !keys[40]) {
        if (player.speed.right) player.position.x -= player.speed.normal;
    }
    if (keys[38] && keys[37]) {
        if (player.speed.up) player.position.y += player.speed.diagonal;
        if (player.speed.left) player.position.x += player.speed.diagonal;
    }
    if (keys[38] && keys[39]) {
        if (player.speed.up) player.position.y += player.speed.diagonal;
        if (player.speed.right) player.position.x -= player.speed.diagonal;
    }
    if (keys[40] && keys[37]) {
        if (player.speed.down) player.position.y -= player.speed.diagonal;
        if (player.speed.left) player.position.x += player.speed.diagonal;
    }
    if (keys[40] && keys[39]) {
        if (player.speed.down) player.position.y -= player.speed.diagonal;
        if (player.speed.right) player.position.x -= player.speed.diagonal;
    }
}

player.position.init()

class solid {
    type;
    x;
    y;
    width;
    height;
    constructor(type, x, y, width, height) {
        this.type = type;
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }
}

const objects = {
    barils: [new solid("baril", 100, 300, 60, 60), new solid("baril", 500, 100, 20, 500), new solid("baril", 500, 100, 500, 20), new solid("baril", 1000, 100, 20, 500), new solid("baril", 500, 600, 520, 20)]
}

console.log(objects)

function draw() {
    context.clearRect(0, 0, canvas.width, canvas.height);
    context.fillStyle = "black";
    context.fillRect(0, 0, canvas.width, canvas.height);
    context.fillStyle = "green";
    context.fillRect(player.position.real.x, player.position.real.y, player.proportion.width, player.proportion.height);

    objects.barils.forEach(element => {
        context.fillStyle = "red";
        context.fillRect(element.x - player.position.x, element.y - player.position.y, element.width, element.height);
        createBlock(element.x - player.position.x, element.y - player.position.y, element.width, element.height);
    });
}

function loop() {
    update();
    draw();
    requestAnimationFrame(loop);
}

loop();
 
  • J’adore
Les réactions: Meow
Picafofo
Générateur d'images
Messages
600
Fofocoins
5 700
Et hop voila votre image !
 

Fichiers joints

  • et si on donnait à picafofo....
    Create an image of a game level with a player character and obstacles. The player character sh...jpg
    54.9 KB · Affichages: 30
ZZZ
Passionné
Messages
1 400
Fofocoins
7 662
Personnalisation du groupe
Personnalisation pseudo
génères-moi un favicon type film pour mon site.
 
Picafofo
Générateur d'images
Messages
600
Fofocoins
5 700
Et hop voila votre image !
 

Fichiers joints

  • et si on donnait à picafofo....
    Génère un favicon représentant un film pour mon site. (1).jpg
    27.5 KB · Affichages: 22
Picafofo
Générateur d'images
Messages
600
Fofocoins
5 700
Et hop voila votre image !
 

Fichiers joints

  • et si on donnait à picafofo....
    A film class with a favicon featuring the text &#039;zzz&#039; (1).jpg
    34 KB · Affichages: 25
Meow
Mythe
Messages
11 440
Age
16
Fofocoins
21 695
Badge : Donuts 🍩
Fond pseudo effet néons
Musique de profil
Plantation d'un arbre via Reforestaction 🌳
Plantation d'un arbre via Reforestaction 🌳
Genre
Fille
du code:

JavaScript:
const canvas = document.getElementById("canvas");
const context = canvas.getContext("2d");

function resizeCanvas() {
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
    canvas.width = document.body.clientWidth;
    canvas.height = document.body.clientHeight + 4;
}

window.addEventListener('resize', resizeCanvas);
resizeCanvas();

var keys = {};
window.addEventListener("keydown", function (event) {
    keys[event.keyCode] = true;
});

window.addEventListener("keyup", function (event) {
    delete keys[event.keyCode];
});

var player = {
    position: {
        x: null,
        y: null,
        init() {
            player.position.x = 0;
            player.position.y = 0;
            player.position.real.x = canvas.width / 2 - player.proportion.head.width / 2
            player.position.real.y = canvas.height / 2 - player.proportion.head.height / 2
        },
        real: {
            x: undefined,
            y: undefined
        }
    },
    proportion: {
        width: 65,
        height: 65,
        head: {
            width: 65,
            height: 65
        }
    },
    speed: {
        normal: -4.5,
        diagonal: -(4.5 / Math.sqrt(2)),
        right: true,
        left: true,
        up: true,
        down: true
    }
}

function createBlock(x, y, width, height, margin = 10) {
    if (keys[37]) {
        if (player.position.real.x - margin <= x + width &&
            player.position.real.x + player.proportion.head.width + margin >= x + width - player.speed.normal) {
            if (
                player.position.real.y >= y &&
                player.position.real.y <= y + height ||
                player.position.real.y + player.proportion.height >= y &&
                player.position.real.y + player.proportion.height <= y + height ||
                player.position.real.y <= y &&
                player.position.real.y + player.proportion.height >= y + height
            ) player.speed.left = false; else player.speed.left = true;
        } else player.speed.left = true;
    }
    if (keys[38]) {
        if (player.position.real.y - margin <= y + height &&
            player.position.real.y + player.proportion.head.height + margin >= y + height - player.speed.normal) {
            if (
                player.position.real.x >= x &&
                player.position.real.x <= x + width ||
                player.position.real.x + player.proportion.width >= x &&
                player.position.real.x + player.proportion.width <= x + width ||
                player.position.real.x <= x &&
                player.position.real.x + player.proportion.width >= x + width
            ) player.speed.up = false; else player.speed.up = true;
        } else player.speed.up = true;
    }
    if (keys[39]) {
        if (player.position.real.x + player.proportion.head.width + margin >= x &&
            player.position.real.x - margin <= x + player.speed.normal) {
            if (
                player.position.real.y >= y &&
                player.position.real.y <= y + height ||
                player.position.real.y + player.proportion.height >= y &&
                player.position.real.y + player.proportion.height <= y + height ||
                player.position.real.y <= y &&
                player.position.real.y + player.proportion.height >= y + height
            ) player.speed.right = false; else player.speed.right = true;
        } else player.speed.right = true;
    }
    if (keys[40]) {
        if (player.position.real.y + player.proportion.head.height + margin >= y &&
            player.position.real.y - margin <= y + player.speed.normal) {
            if (
                player.position.real.x >= x &&
                player.position.real.x <= x + width ||
                player.position.real.x + player.proportion.height >= x &&
                player.position.real.x + player.proportion.height <= x + width ||
                player.position.real.x <= x &&
                player.position.real.x + player.proportion.height >= x + width
            ) player.speed.down = false; else player.speed.down = true;
        } else player.speed.down = true;
    }
}

function update() {
    if (keys[38] && !keys[37] && !keys[39]) {
        if (player.speed.up) player.position.y += player.speed.normal;
    }
    if (keys[40] && !keys[37] && !keys[39]) {
        if (player.speed.down) player.position.y -= player.speed.normal;
    }
    if (keys[37] && !keys[38] && !keys[40]) {
        if (player.speed.left) player.position.x += player.speed.normal;
    }
    if (keys[39] && !keys[38] && !keys[40]) {
        if (player.speed.right) player.position.x -= player.speed.normal;
    }
    if (keys[38] && keys[37]) {
        if (player.speed.up) player.position.y += player.speed.diagonal;
        if (player.speed.left) player.position.x += player.speed.diagonal;
    }
    if (keys[38] && keys[39]) {
        if (player.speed.up) player.position.y += player.speed.diagonal;
        if (player.speed.right) player.position.x -= player.speed.diagonal;
    }
    if (keys[40] && keys[37]) {
        if (player.speed.down) player.position.y -= player.speed.diagonal;
        if (player.speed.left) player.position.x += player.speed.diagonal;
    }
    if (keys[40] && keys[39]) {
        if (player.speed.down) player.position.y -= player.speed.diagonal;
        if (player.speed.right) player.position.x -= player.speed.diagonal;
    }
}

player.position.init()

class solid {
    type;
    x;
    y;
    width;
    height;
    constructor(type, x, y, width, height) {
        this.type = type;
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }
}

const objects = {
    barils: [new solid("baril", 100, 300, 60, 60), new solid("baril", 500, 100, 20, 500), new solid("baril", 500, 100, 500, 20), new solid("baril", 1000, 100, 20, 500), new solid("baril", 500, 600, 520, 20)]
}

console.log(objects)

function draw() {
    context.clearRect(0, 0, canvas.width, canvas.height);
    context.fillStyle = "black";
    context.fillRect(0, 0, canvas.width, canvas.height);
    context.fillStyle = "green";
    context.fillRect(player.position.real.x, player.position.real.y, player.proportion.width, player.proportion.height);

    objects.barils.forEach(element => {
        context.fillStyle = "red";
        context.fillRect(element.x - player.position.x, element.y - player.position.y, element.width, element.height);
        createBlock(element.x - player.position.x, element.y - player.position.y, element.width, element.height);
    });
}

function loop() {
    update();
    draw();
    requestAnimationFrame(loop);
}

loop();
Et hop voila votre image !
Oh mais c'est super, P Picafofo peut lire les codes !!
 
Picafofo
Générateur d'images
Messages
600
Fofocoins
5 700
Et hop voila votre image !
 

Fichiers joints

  • et si on donnait à picafofo....
    A canvas with a player character moving around obstacles (1).jpg
    66.7 KB · Affichages: 22
  • Haha
Les réactions: Meow
ZZZ
Passionné
Messages
1 400
Fofocoins
7 662
Personnalisation du groupe
Personnalisation pseudo
Oh mais c'est super, P Picafofo peut lire les codes !!
Oui, enfin, le code que je lui ai donné, ça donne ça en vrai :

et si on donnait à picafofo....


On est très loin de ce que lui a donné. Pour l'instant mon code ne gère que les déplacements et les hitboxs (celle du joueur en vert, celles des obstacles en rouge).
 
  • J’aime
Les réactions: Meow
Picafofo
Générateur d'images
Messages
600
Fofocoins
5 700
Et hop voila votre image !
 

Fichiers joints

  • et si on donnait à picafofo....
    Décrivez ce qui doit être dans l&#039;image. (1).jpg
    65.3 KB · Affichages: 20
Chuck 🐯
Légende
Messages
5 703
Age
16
Fofocoins
33 997
Badge : Donuts 🍩
Personnalisation pseudo
Plantation d'un arbre via Reforestaction 🌳
Plantation d'un arbre via Reforestaction 🌳
Genre
Garçon
Et hop voila votre image !
Mais c'est génial !
Je savais pas qu'il pouvait générer un jeu à partir d'un script... :cool:
Je me demande si ça marche avec scratch...Il faudra que j'essaye 🤨
Bon après ce n'est pas du tout comme scratch puisque l'image ne peut pas s'animer, mais c'est bon à savoir U_U
 
  • J’aime
Les réactions: Meow
Picafofo
Générateur d'images
Messages
600
Fofocoins
5 700
Et hop voila votre image !
 

Fichiers joints

  • et si on donnait à picafofo....
    Create an image of a game generated from a script. (1).jpg
    46.3 KB · Affichages: 23
Picafofo
Générateur d'images
Messages
600
Fofocoins
5 700
Et hop voila votre image !
 

Fichiers joints

  • et si on donnait à picafofo....
    A picture of a baby koala (1).jpg
    138.4 KB · Affichages: 21
Picafofo
Générateur d'images
Messages
600
Fofocoins
5 700
Et hop voila votre image !
 

Fichiers joints

  • et si on donnait à picafofo....
    An image of a lama. (1).jpg
    82.6 KB · Affichages: 19
Picafofo
Générateur d'images
Messages
600
Fofocoins
5 700
Et hop voila votre image !
 

Fichiers joints

  • et si on donnait à picafofo....
    A cute llama (1).jpg
    102.1 KB · Affichages: 23
Picafofo
Générateur d'images
Messages
600
Fofocoins
5 700
Et hop voila votre image !
 

Fichiers joints

  • et si on donnait à picafofo....
    A picture of a person being spat on by a llama (1).jpg
    107.3 KB · Affichages: 22
Un forum engagé, des associations renforcées
Faites des dons grace à vos Fofocoins !
Les associations du moment