boat.e0000644000175000017500000000551611521656316010332 0ustar evoevo %eden boaty = 400.0; boatx = 400.0; boatSpeedX = 0.0; boatSpeedY = 0.0; ##boat has its own power source. Moves boat forward at speed boatpowerspeed boatPowerSpeed = 0.5; boatEngineOn = 0; boatRotation = 0; boatRotationMod360 is boatRotation % 360; boatRotationSpeed = 0.4; ##current boat spin speed, in degrees boatRotationInRads is (0 - (boatRotation % 360)) / (180 / pi); engineFriction = 0.7; crashed = 0; proc applyEnginePower { if (boatEngineOn==1) { boatXDifferenceInSpeed = boatSpeedX + (boatPowerSpeed * sin(boatRotationInRads)); boatYDifferenceInSpeed = boatSpeedY - (boatPowerSpeed * cos(boatRotationInRads)); boatSpeedX = boatSpeedX - ((boatXDifferenceInSpeed * engineFriction) / ticksInSecond); boatSpeedY = boatSpeedY - ((boatYDifferenceInSpeed * engineFriction) / ticksInSecond); } } proc moveBoatRotationSpin { boatRotation = boatRotation + boatRotationSpeed; } proc processBoatSpeed { if (boatx < 100.0) { crashed = 1; } if (boatx > 900.0) { crashed = 1; } if (crashed == 0) { boaty = boaty + boatSpeedY; boatx = boatx + boatSpeedX; } if (boaty < 0) { boaty = length; } if (boaty > length) { boaty = 0; } } %donald viewport IMAGINARY openshape boat within boat { point backleft point backright point frontleft point frontright point bow point boatmiddle #virtual point in middle of boat int boatlength int boatwidth int bowlength real boatrotation real rotation #the total length of boat = boatlength + bowlength boatlength = 50 boatwidth = 30 bowlength = 10 rotation = boatRotation! boatrotation = 0.0 boatmiddle = {boatx!, boaty!} boatrotation = (0 - rotation) div (180 div pi) backleft = boatmiddle + {0 - boatwidth div 2, 0 - boatlength div 2} backright = boatmiddle + {boatwidth div 2, 0 - boatlength div 2} frontleft = boatmiddle + {0 - boatwidth div 2, boatlength div 2} frontright = boatmiddle + {boatwidth div 2, boatlength div 2} bow = boatmiddle + {0, (boatlength div 2) + bowlength} line stern line port line starboard line bowport line bowstarboard stern = [backleft, backright] port = [backleft, frontleft] starboard = [backright, frontright] bowport = [frontleft, bow] bowstarboard = [frontright, bow] } %donald viewport model shape boat2 boat2 = rot(boat, boat/boatmiddle, boat/boatrotation) #boat2 = trans(boat, 20, 20) label l1 l1 = label("Heading: " // rtos(boatRotationMod360!, "0.f" // " degrees"), {300, 100}) label l2 l2 = label("SpeedY: " // rtos(boatSpeedY!, "f"), {300, 130}) label l3 l3 = label("SpeedX: " // rtos(boatSpeedX!, "f"), {300, 160}) buttons.s0000644000175000017500000000741311515432362011113 0ustar evoevo%donald %scout string engineToggle, up, down, windToggle, currentToggle; window engineWindow; box engineBox; point base; down = "<"; up = ">"; base = {1.c, 20.r}; engineWindow = { frame: (engineBox), string: engineToggle, fgcolor: "black", bgcolor: "white", sensitive: ON }; engineToggle = "Toggle Engine"; engineBox = [base, 1, strlen(engineToggle)]; window engineWindowDown; box engineBoxDown; engineWindowDown = { frame: (engineBoxDown), string: down, fgcolor: "black", bgcolor: "white", sensitive: ON }; engineBoxDown = [base + {0.c, 2.c}, 1, strlen(down)]; window engineWindowUp; box engineBoxUp; engineWindowUp = { frame: (engineBoxUp), string: up, fgcolor: "black", bgcolor: "white", sensitive: ON }; engineBoxUp = [base + {2.c, 2.c}, 1, strlen(up)]; window windWindow; box windBox; windWindow = { frame: (windBox), string: windToggle, fgcolor: "black", bgcolor: "white", sensitive: ON }; windToggle = "Toggle wind"; windBox = [base + {0.c, 5.c}, 1, strlen(windToggle)]; window windWindowDown; box windBoxDown; windWindowDown = { frame: (windBoxDown), string: down, fgcolor: "black", bgcolor: "white", sensitive: ON }; windBoxDown = [base + {0.c, 7.c}, 1, strlen(down)]; window windWindowUp; box windBoxUp; windWindowUp = { frame: (windBoxUp), string: up, fgcolor: "black", bgcolor: "white", sensitive: ON }; windBoxUp = [base + {2.c, 7.c}, 1, strlen(up)]; window currentWindow; box currentBox; currentWindow = { frame: (currentBox), string: currentToggle, fgcolor: "black", bgcolor: "white", sensitive: ON }; currentToggle = "Toggle Current"; currentBox = [base + {0.c, 10.c}, 1, strlen(currentToggle)]; window currentWindowDown; box currentBoxDown; currentWindowDown = { frame: (currentBoxDown), string: down, fgcolor: "black", bgcolor: "white", sensitive: ON }; currentBoxDown = [base + {0.c, 12.c}, 1, strlen(down)]; window currentWindowUp; box currentBoxUp; currentWindowUp = { frame: (currentBoxUp), string: up, fgcolor: "black", bgcolor: "white", sensitive: ON }; currentBoxUp = [base + {2.c, 12.c}, 1, strlen(up)]; %eden proc engineWindow_button : engineWindow_mouse_1 { if (engineWindow_mouse_1[2] == 4) if (boatEngineOn == 1) { boatEngineOn = 0; } else { boatEngineOn = 1; } } proc engineWindowUp_button : engineWindowUp_mouse_1 { if (engineWindowUp_mouse_1[2] == 4) boatPowerSpeed = boatPowerSpeed + 0.1; } proc engineWindowDown_button : engineWindowDown_mouse_1 { if (engineWindowDown_mouse_1[2] == 4) boatPowerSpeed = boatPowerSpeed - 0.1; } proc windWindow_button : windWindow_mouse_1 { if (windWindow_mouse_1[2] == 4) if (windEnabled == 1) { windEnabled = 0; } else { windEnabled = 1; } } proc windWindowUp_button : windWindowUp_mouse_1 { if (windWindowUp_mouse_1[2] == 4) windSpeed = windSpeed + 0.1; } proc windWindowDown_button : windWindowDown_mouse_1 { if (windWindowDown_mouse_1[2] == 4) windSpeed = windSpeed - 0.1; } proc currentWindow_button : currentWindow_mouse_1 { if (currentWindow_mouse_1[2] == 4) if (currentEnabled == 1) { currentEnabled = 0; } else { currentEnabled = 1; } } proc currentWindowUp_button : currentWindowUp_mouse_1 { if (currentWindowUp_mouse_1[2] == 4) speedOfCurrent = speedOfCurrent + 0.1; } proc currentWindowDown_button : currentWindowDown_mouse_1 { if (currentWindowDown_mouse_1[2] == 4) speedOfCurrent = speedOfCurrent - 0.1; } %scout window modelWindow = { type: DONALD box: [{200, 200}, {1000, 1000}] pict: "model" xmin: 0 ymin: 0 xmax: 1000 ymax: 1000 bgcolor: "white" border: 1 }; screen = < modelWindow / engineWindow / engineWindowUp / engineWindowDown / windWindow / windWindowDown / windWindowUp / currentWindow / currentWindowUp / currentWindowDown >; current.e0000644000175000017500000000050311520424225011045 0ustar evoevo%eden speedOfCurrent = -1; frictionOfCurrent = 1; currentEnabled = 0; proc moveBoatCurrent { if (currentEnabled==1) { engineDifferenceInSpeed = boatSpeedY - speedOfCurrent; boatSpeedY = boatSpeedY - ((engineDifferenceInSpeed * frictionOfCurrent) / ticksInSecond); } } river.e0000644000175000017500000000064611515075504010530 0ustar evoevo%donald #the river is 2 lines int width #width of river int length point NW, NE, SW, SE line W, E #two sides of river #W = [NW, SW] #E = [NE, SE] rectangle riverrec riverrec = rectangle(SW, NE) SW = {100, 0} SE = SW + {width, 0} # The other 3 corners are relative NE = SW + {width, length} # to South-West corner. NW = SW + {0, length} width = 800 length = 1000 %eden A_riverrec is "fill=solid,color=lightblue"; run.e0000644000175000017500000000026011515077112010172 0ustar evoevo%eden pi = 3.14159265; %donald viewport model %eden include("river.e"); include("boat.e"); include("current.e"); include("wind.e"); include("timer.e"); include("buttons.s"); timer.e0000644000175000017500000000040711517421725010516 0ustar evoevo%eden tickTime = 10; ticksInSecond is 1000 / tickTime; edenclocks = [[&tick, tickTime]]; tick360 is tick % 360; proc moveBoat : tick { moveBoatWind(); moveBoatCurrent(); applyEnginePower(); moveBoatRotationSpin(); processBoatSpeed(); } wind.e0000644000175000017500000000115611521655513010340 0ustar evoevo%eden windSpeed = 1; windDirection = 270; /* bearing from 0, in degrees */ windEnabled = 0; windFriction = 0.6; windDirectionInRads = windDirection / (180 / pi); proc moveBoatWind { if (windEnabled==1) { windXDifferenceInSpeed = boatSpeedX - (windSpeed * sin(windDirectionInRads)); windYDifferenceInSpeed = boatSpeedY - (windSpeed * cos(windDirectionInRads)); boatSpeedX = boatSpeedX - ((windXDifferenceInSpeed * windFriction) / ticksInSecond); boatSpeedY = boatSpeedY - ((windYDifferenceInSpeed * windFriction) / ticksInSecond); } }