-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgravity.bas
75 lines (55 loc) · 1.5 KB
/
gravity.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
CLS
SCREEN 12
LET pi = 3.14159
LET accely = 0
LET ballx = 100
LET bally = 100
INPUT "Initial X Acceleration: ", accelx
CLS
LINE (0, 0)-(640, 480), 15, BF
FOR w = 1 TO 1000000
NEXT w
DO
CIRCLE (ballx, bally), 20, 15
LINE (COS(ballangle) * 20 + ballx, SIN(ballangle) * 20 + bally)-(COS(ballangle) * -20 + ballx, SIN(ballangle) * -20 + bally), 15
IF ballangle >= 2 * pi THEN LET ballangle = ballangle - 2 * pi
'###################### Y CONTROL #######################
IF bally + 20 < 480 AND accely < 4 THEN
LET accely = accely + .06
END IF
IF accely <> 0 THEN
LET bally = bally + accely
END IF
'###################### X CONTROL #######################
'This should work
IF ballx + 20 >= 640 AND accelx > 0 THEN
LET accelx = accelx * -.5
ELSEIF ballx - 20 <= 0 AND accelx < 0 THEN
LET accelx = accelx * -.5
END IF
IF accely > 0 AND bally + 20 >= 480 THEN
LET accely = accely * -.6
IF accelx > 0 THEN
LET accelx = accelx - .05
ELSEIF accelx < 0 THEN
LET accelx = accelx + .05
END IF
ELSEIF accely <= 0 THEN
IF accelx > 0 THEN
LET accelx = accelx - .002
ELSEIF accelx < 0 THEN
LET accelx = accelx + .002
END IF
END IF
IF accelx <> 0 THEN
LET ballx = ballx + accelx
LET ballangle = ballangle + accelx / pi / 10
END IF
'###################### DRAW #######################
CIRCLE (ballx, bally), 20, 0
LINE (COS(ballangle) * 20 + ballx, SIN(ballangle) * 20 + bally)-(COS(ballangle) * -20 + ballx, SIN(ballangle) * -20 + bally), 0
LET key$ = INKEY$
FOR w = 1 TO 40000
IF key$ <> "" THEN END
NEXT w
LOOP