|
Post by picachu on Apr 17, 2018 21:51:37 GMT
Good. Well here I am with another doubt, before I start doing my first spectrum game. In the engine that I use to make PC and Android games, there is a function called alarm. This what it does is that after certain frames, an action is carried out. In A.G.D or in Basic, is there something similar I'm sorry to ask so much, but before I start doing anything, I'd like to have at least some basic questions by hand. Thank you very much in advance. Regards!!!
|
|
|
Post by nra on Apr 18, 2018 19:02:47 GMT
Indeed, some one-time, planned, or delay action would be nice, yet it requires even more counters.
Meanwhile there's a read-only CLOCK var updated 1/25th second, so you can tweak with it.
|
|
|
Post by lukebord1 on Apr 19, 2018 6:49:59 GMT
If the purpose is to set a timer, it's possible to use global variables in the MAIN LOOP event, e.g. to avoid too quick animations. Obviously, the higher the limit, the slower the time. Here's an example on how use two different timers to animate and "blink" a sprite:
Main Loop: IF A > 0 LET A = 0 ELSE LET A = 1 ENDIF
IF B > 14 LET B = 0 ELSE ADD 1 TO B ENDIF
Sprite Event: IF A = 1 ANIMATE ENDIF
IF B = 14 SPRITEINK 71 ELSE SPRITEINK 0 ENDIF
As you can see, the syntax logic is very direct and clear (very close to the Basic Language), however, it's important to understand that AGD events are "cyclic", that is, every event is a loop which stops at a kill event, a victory (completed game event) or an end (lost game event). Outside these loops there are the initialisation events, e.g. the "initialisation game" event where you have to set the variables, and the "sprite initialisation" where you can tell what's happening at the very first sprite type spawn.
You can learn more by watching the AGD video tutorials by Paul Jenkinson.
|
|
|
Post by nra on Apr 19, 2018 10:33:50 GMT
Hello, Luke.
In this case I would use a bit different approach such as:
LET A=CLOCK LET B=A DIVIDE A BY 10 MULTIPLY A BY 10
IF A=B ANIMATE ENDIF , where 10 is a tempo and the whole code is but a replacement for IF CLOCK MOD 10=0 THEN ANIMATE
|
|
|
Post by picachu on Apr 19, 2018 17:14:25 GMT
Use of variables in the loop. It could be a solution. Yes sir. Thank you very much.
|
|