14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Rafael Assis Santos
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/sketch.js:
--------------------------------------------------------------------------------
1 | function setup() {
2 | createCanvas(400, 400);
3 | }
4 |
5 | function draw() {
6 | background(51);
7 | }
8 | function setup() {
9 | createCanvas(400, 400);
10 | }
11 |
12 | function draw() {
13 | background(51);
14 | rect(200,200,10,10)
15 | }
16 | // variáveis da cobrinha
17 | let xCobra = 50;
18 | let yCobra = 40;
19 | let wCobra = 10;
20 | let hCobra = 10;
21 |
22 | // velocidade da movimentação
23 | let velocidadeMovimentacao = 8;
24 |
25 | function setup() {
26 | createCanvas(1600, 400);
27 | }
28 |
29 | function draw() {
30 | background(1);
31 | rect(xCobra, yCobra, wCobra, hCobra);
32 | // adiciona comandos para as setinhas
33 | if (keyIsDown(LEFT_ARROW)) {
34 | xCobra -= velocidadeMovimentacao;
35 | }
36 | if (keyIsDown(RIGHT_ARROW)) {
37 | xCobra += velocidadeMovimentacao;
38 | }
39 | if (keyIsDown(UP_ARROW)) {
40 | yCobra -= velocidadeMovimentacao;
41 | }
42 | if (keyIsDown(DOWN_ARROW)) {
43 | yCobra += velocidadeMovimentacao;
44 | }
45 | }
46 |
47 |
--------------------------------------------------------------------------------