-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path1448.html
More file actions
142 lines (142 loc) · 11 KB
/
Copy path1448.html
File metadata and controls
142 lines (142 loc) · 11 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SmallBASIC | TICKS</title>
<meta name="description" content="Returns the number of milliseconds that have elapsed between successive calls.">
<link rel="canonical" href="1448">
<link rel="keywords" href="TICKS">
<link rel="stylesheet" href="/css/style.css">
<link rel="icon" type="image/png" href="/images/sb-desktop-32x32.png">
<script src="/clipboard.js"></script>
</head>
<body>
<button onclick="topFunction()" id="BackToTopBtn" title="Go to top">⯅</button>
<script src="/backtotop.js"></script>
<div class="wrapAll clearfix">
<nav class="navigation">
<div class="logo">
<a href="/"><img src='/images/sb-logo.png?v=2' alt="logo"></a>
</div>
<div class="navlinks">
<a href="/pages/download.html">Download</a>
<a href="/pages/news.html">News</a>
<a href="/pages/community.html">Community</a>
<a href="/pages/articles.html">Resources</a>
<a class='active' href="/pages/reference.html">Language Reference</a>
<a href="/pages/guide.html">SmallBASIC Manual</a>
</div>
</nav>
<div class="mainsection">
<div class="tabs clearfix">
<div class="tabsRight">
<a target="_github" href="https://github.com/smallbasic/smallbasic.github.io/blob/master/_build/reference/1448-date-ticks.markdown">Edit</a>
<a target="_github" href="https://github.com/smallbasic/smallbasic.github.io/commits/master/_build/reference/1448-date-ticks.markdown">History</a>
</div>
</div>
<div class="article">
<h1>TICKS</h1>
<blockquote>n = TICKS</blockquote>
<div class="siteSub">
<p>
<a href="/">Home</a> >
<a href="/pages/reference.html">Reference</a> >
<a href="/pages/date.html">Date</a>
</p>
</div>
<p>Returns the number of milliseconds that have elapsed since start of
the operating system.</p>
<h3 id="example-1">Example 1:</h3>
<div class="sourceCode" id="cb1"><pre
class="sourceCode smallbasic"><code class="sourceCode smallbasic"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>t = <span class="fu">ticks</span>()</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="kw">print</span> t</span></code></pre></div>
<h3 id="example-2-game-with-constant-frame-rate">Example 2: Game with
constant frame rate</h3>
<div class="sourceCode" id="cb2"><pre
class="sourceCode smallbasic"><code class="sourceCode smallbasic"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co">' ticks() can be used to let your game</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="co">' run with a constant frame rate</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>FramesPerSecond = <span class="dv">20</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="kw">for </span>xx = <span class="dv">1</span> <span class="kw">to</span> <span class="dv">200</span></span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a> StartTime = <span class="fu">ticks</span>()</span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a> <span class="co">'Put your heavy computions here</span></span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">cls</span></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">rect</span> <span class="dv">10</span> + xx, <span class="dv">10</span>, <span class="dv">50</span>+xx, <span class="dv">50</span></span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">showpage</span></span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a> <span class="co">'Delay the execution of the for-loop </span></span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a> StopTime = <span class="fu">ticks</span>()</span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a> ElapsedTime = StopTime - StartTime</span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-20"><a href="#cb2-20" aria-hidden="true" tabindex="-1"></a> <span class="kw">if(</span>ElapsedTime < <span class="dv">1000</span> / FramesPerSecond)</span>
<span id="cb2-21"><a href="#cb2-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">delay</span>(<span class="dv">1000</span> / FramesPerSecond - ElapsedTime)</span>
<span id="cb2-22"><a href="#cb2-22" aria-hidden="true" tabindex="-1"></a> <span class="kw">endif</span></span>
<span id="cb2-23"><a href="#cb2-23" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-24"><a href="#cb2-24" aria-hidden="true" tabindex="-1"></a><span class="kw">next</span></span></code></pre></div>
<div class="lavenderBox">
<div class="header">Code samples using TICKS</div>
<div class="linklist">
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 3/2048.bas">2048.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 2/3d rotating cube with message.bas">3d rotating cube with message.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 1/3d_torus.bas">3d_torus.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 2/3dtorus.bas">3dtorus.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/7gables.bas">7gables.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/applications/analog clock.bas">analog clock.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/anball 1.0.bas">anball 1.0.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/Ball.bas">Ball.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/balls in 3d cube.bas">balls in 3d cube.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/circ.bas">circ.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/mechanics/duty.bas">duty.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/system/evdemo.bas">evdemo.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/mathematics/first factors mga.bas">first factors mga.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/fizzle2.bas">fizzle2.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/utilities/golpes_x_min2.bas">golpes_x_min2.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 2/hangman v2.bas">hangman v2.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/hangman.bas">hangman.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/maps.bas">maps.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 2/maze generator.bas">maze generator.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 1/ping-pong.bas">ping-pong.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/pirate.bas">pirate.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/plasma2.bas">plasma2.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/polyline.bas">polyline.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/mathematics/primes.bas">primes.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/sound/scales132.bas">scales132.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/system/screen info.bas">screen info.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 3/sierpinski in space.bas">sierpinski in space.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/space.bas">space.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Peter Graphics/try rainbow v2.bas">try rainbow v2.bas </a>
</div>
</div>
<div class="lavenderBox">
<div class="header">Date</div>
<div class="linklist">
<a href="/reference/575.html">DATE </a>
<a href="/reference/573.html">DATEDMY </a>
<a href="/reference/576.html">DATEFMT </a>
<a href="/reference/577.html">JULIAN </a>
<a href="/reference/1448.html"><strong>TICKS</strong> </a>
<a href="/reference/578.html">TIME </a>
<a href="/reference/574.html">TIMEHMS </a>
<a href="/reference/1449.html">TIMER </a>
<a href="/reference/1450.html">TIMESTAMP </a>
<a href="/reference/579.html">WEEKDAY </a>
</div>
</div>
</div>
<div class="pagefooter">
This page was last edited on Fri, 1 Sep 2023 16:02:30 +0200
|
<a href="https://en.wikipedia.org/wiki/Markdown" target="_blank" rel="nofollow">Markdown</a>
processed with
<a href="https://pandoc.org/MANUAL.html#pandocs-markdown" target="_blank" rel="nofollow">pandoc 3.1.12.1</a>
</div>
</div>
</div>
</body>
</html>