ncsa / lab-dragon

Home for Lab Dragon - A new costumizable and powerful electronic lab notebook
https://toolsforexperiments.github.io/labcore/
MIT License
2 stars 2 forks source link

Workspace #90

Open marcosfrenkel opened 3 weeks ago

marcosfrenkel commented 3 weeks ago

Workspace Component breakdown

General Workspace sections

Image

Task breakdown

Image

Step viewer breakdown

Image

Code Tasks

ukpemkpo commented 2 weeks ago

what is wrong with the below code

lang racket

(require 2htdp/universe) (require 2htdp/image)

;; Constants (define WIDTH 400) (define HEIGHT 400) (define BG-COLOR (make-color 173 216 230)) ;; Light blue color (define CIRCLE-RADIUS 20)

;; Define the initial state (position of a ball) (define initial-pos (convert make-posn 200 200)) ;; Corrected definition of initial-pos

;; Render function: Draws the playground (circle at position) (define (render-playground pos) (place-image (circle CIRCLE-RADIUS "solid" "red") ;; Draw the circle (ball) (posn-x pos) (posn-y pos) ;; Position of the ball (empty-scene WIDTH HEIGHT BG-COLOR))) ;; Background color for playground

;; Update function: Moves the ball based on key events (define (move pos key) (cond [(key=? key "left") (make-posn (max 0 (- (posn-x pos) 10)) (posn-y pos))] [(key=? key "right") (make-posn (min WIDTH (+ (posn-x pos) 10)) (posn-y pos))] [(key=? key "up") (make-posn (posn-x pos) (max 0 (- (posn-y pos) 10)))] [(key=? key "down") (make-posn (posn-x pos) (min HEIGHT (+ (posn-y pos) 10)))] [else pos]))

;; Main function to start the world (big-bang initial-pos (to-draw render-playground) ;; How to render the playground (on-key move)) ;; Handle key events (move the ball)