Skip to content

Commit

Permalink
Writing a JS webapp
Browse files Browse the repository at this point in the history
  • Loading branch information
ker2x committed Feb 12, 2024
1 parent a3e8171 commit 473d418
Showing 1 changed file with 77 additions and 1 deletion.
78 changes: 77 additions & 1 deletion Writerside/topics/A-full-project-using-LLM-only.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,5 +439,81 @@ body {
I still didn't write a single line of code or comment.
I didn't use auto-completion.

Just a dialog with AI Assistant.
Just a dialog with AI Assistant. I have no idea what i'm doing. It works.

## toggle grid

I asked GitHub Copilot for a change

```Javascript
"use strict";

// Constants definition
const CANVAS_SIZE = 1024;
const UPDATE_INTERVAL = 1000 / 60;
const GRID_SIZE = 128;
const GRID_CELL_SIZE = CANVAS_SIZE / GRID_SIZE;

let canvas;
let context;
let isDrawingEnabled = true; // Add this line

// Define setup function
function setup() {
// ... existing code ...
}

function setupCanvas(canvas, context) {
// ... existing code ...
}

// Define drawGrid function
function drawGrid() {
// ... existing code ...
}

// Update draw function
function draw() {
// Clear the current canvas
context.clearRect(0, 0, canvas.width, canvas.height);
// Redraw the setup canvas
//setupCanvas(canvas, context);
// Draw the grid only if isDrawingEnabled is true
if (isDrawingEnabled) {
drawGrid();
}
requestAnimationFrame(draw);
}

function update() {
// ... existing code ...
}

function handleKeydown(event) {
// If 'r' key is pressed, toggle isDrawingEnabled
if (event.key === 'r') {
isDrawingEnabled = !isDrawingEnabled;
}
console.log('Keydown event: ', event.key);
}

function handleMouseEvent(event) {
// ... existing code ...
}

setup();
setInterval(update, UPDATE_INTERVAL);
requestAnimationFrame(draw);
```
And commented to call to `setupCanvas` in `draw` function, manually.
It's there for a reason, (if the display size change) but i don't care.

## A problem with AI Assistant

I'm facing a frustrating problem. AI Assistant doesn't know the context of the code.
Unless a specifically provide the code in the prompt, the answer will always be out of context as if i was not in an IDE.
Providing the code gets me the right answer, but it's not practical when there is a lot of code in multiple files.

I don't know what to do. I'll ask AI Assistant, of course, but my guess is that i'll have to do some good old google search. (laaaame!)


0 comments on commit 473d418

Please sign in to comment.