Using Updatescreen in Game Loops (Game Academy)
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Using Updatescreen in Game Loops (Game Academy)
Hi
In the first video from the Game Academy, Hanson mentions that in order to make game loops that an "UpdateScreen" message is needed. He goes on to say that it is currently not implemented in Livecode, but will be implemented in the coming weeks. That I don't need to worry about it.
Well, it's been 2 years since the video, and I cannot find "Updatescreen" message in the livecode dictionary. SO what do I do in order to make a simple game loop? Has "UpdateScreen" been implemented in Livecode? Do I use an "On idle" handler? Does anyone know the game loop code for starting and stopping objects?
The academy is great, but I still do not know how to make game loops.
Max
In the first video from the Game Academy, Hanson mentions that in order to make game loops that an "UpdateScreen" message is needed. He goes on to say that it is currently not implemented in Livecode, but will be implemented in the coming weeks. That I don't need to worry about it.
Well, it's been 2 years since the video, and I cannot find "Updatescreen" message in the livecode dictionary. SO what do I do in order to make a simple game loop? Has "UpdateScreen" been implemented in Livecode? Do I use an "On idle" handler? Does anyone know the game loop code for starting and stopping objects?
The academy is great, but I still do not know how to make game loops.
Max
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Using Updatescreen in Game Loops (Game Academy)
Hi Max,
I never use Updatescreen
What do you use for your loop ?
• "repeat" or "send in time"
I often heard that using idle seems not a good way and "send in time" is better than repeat
I use "send in time" without Updatescreen and it works fine for me
Best regards
Jean-Marc
I never use Updatescreen
What do you use for your loop ?
• "repeat" or "send in time"
I often heard that using idle seems not a good way and "send in time" is better than repeat
I use "send in time" without Updatescreen and it works fine for me
Best regards
Jean-Marc
https://alternatic.ch
Re: Using Updatescreen in Game Loops (Game Academy)
Do you mean like:
local sTime
on mouseUp
put 0 into sTime
send "timerIncrement" to me in 1 seconds
end mouseUp
on timerIncrement
add 1 to sTime
put sTime
send "timerIncrement" to me in 1 seconds
end timerIncrement
SO I guess this may be better than updatescreen. I can't find it in the dictionary anyway. Thanks.
local sTime
on mouseUp
put 0 into sTime
send "timerIncrement" to me in 1 seconds
end mouseUp
on timerIncrement
add 1 to sTime
put sTime
send "timerIncrement" to me in 1 seconds
end timerIncrement
SO I guess this may be better than updatescreen. I can't find it in the dictionary anyway. Thanks.
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Using Updatescreen in Game Loops (Game Academy)
Yes.
Don't forget delete pending message to avoïd unnecessary pendingmessages
Don't forget delete pending message to avoïd unnecessary pendingmessages
Code: Select all
--••stop one pending pMessage
on doStopPending pMessage
repeat for each line aLine in the pendingmessages
if pMessage is in item 1 of aLine then
cancel item 1 of aLine
end if
end repeat
end doStopPending
https://alternatic.ch
Re: Using Updatescreen in Game Loops (Game Academy)
Thank you for the PendingMesseges tip.
Max
Max
Re: Using Updatescreen in Game Loops (Game Academy)
updatescreen is code provided during the academy to generate the loop. it actually works pretty well, the result being an updatecreen message that is dispatched every 50 milliseconds. (20fps) (if I recall correctly).
Updatescreen was never implemented in the engine, but the stackscript that was provided does a good job. At that point, its a simple matter to utilize.
on updatescreen
if not sGameRunning then exit updatescreen
checkthisstuff
checkthatstuff
lookforcollisoins
dowhateverelse
end updatescreen
The biggest issue, whether writing your own loop, or using the code provided by David Williams, is if you're stacking too much to be accomplished in 50ms. For things like movement, its important to track time and use the difference between then and now as part of your movement scaling.
I haven't needed to worry about the scaling with the things I've done so far, so wouldn't be much help with that. If you want to see some simple examples using the gameloop, I can post a very very basic breakeout start, as well as a rocket you can fly around the screen (it shoots too!) Also, if I can locate it, I have an example of rolling a ball around screen using accelerometers. On desktop, a yellow controlbox appears that you cna click and hold, them move the mouse to simulate accelerometer movement. My wall detection in that one needs a major revamp though, so i'm waiting for box2d.
EDIT to add zip of stack files.
Updatescreen was never implemented in the engine, but the stackscript that was provided does a good job. At that point, its a simple matter to utilize.
on updatescreen
if not sGameRunning then exit updatescreen
checkthisstuff
checkthatstuff
lookforcollisoins
dowhateverelse
end updatescreen
The biggest issue, whether writing your own loop, or using the code provided by David Williams, is if you're stacking too much to be accomplished in 50ms. For things like movement, its important to track time and use the difference between then and now as part of your movement scaling.
I haven't needed to worry about the scaling with the things I've done so far, so wouldn't be much help with that. If you want to see some simple examples using the gameloop, I can post a very very basic breakeout start, as well as a rocket you can fly around the screen (it shoots too!) Also, if I can locate it, I have an example of rolling a ball around screen using accelerometers. On desktop, a yellow controlbox appears that you cna click and hold, them move the mouse to simulate accelerometer movement. My wall detection in that one needs a major revamp though, so i'm waiting for box2d.
EDIT to add zip of stack files.
Re: Using Updatescreen in Game Loops (Game Academy)
File was too big, so heres a dropbox link to it. https://dl.dropboxusercontent.com/u/119 ... estuff.zip
Re: Using Updatescreen in Game Loops (Game Academy)
Thank you. All three for your files are terrific. Max
-
- VIP Livecode Opensource Backer
- Posts: 327
- Joined: Sun Apr 15, 2012 1:17 am
- Location: USA
- Contact:
Re: Using Updatescreen in Game Loops (Game Academy)
There are a few tutorials and examples here:
https://sites.google.com/a/pgcps.org/li ... rogramming
https://sites.google.com/a/pgcps.org/li ... rogramming
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/
Re: Using Updatescreen in Game Loops (Game Academy)
Feel free to use them for whatever. Be aware though, the images in the asteroid framework, I've no clue where I got them, so you'd want to make sure to replace them with something else for legality sake.maxs wrote:Thank you. All three for your files are terrific. Max
Re: Using Updatescreen in Game Loops (Game Academy)
These are terrific resources I never knew about. Thanks. Who made these?
Max
There are a few tutorials and examples here:
https://sites.google.com/a/pgcps.org/li ... rogramming
Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 137
Joined: Sun Apr 15, 2012 12:17 am
Location: USA
Max
There are a few tutorials and examples here:
https://sites.google.com/a/pgcps.org/li ... rogramming
Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 137
Joined: Sun Apr 15, 2012 12:17 am
Location: USA
-
- VIP Livecode Opensource Backer
- Posts: 327
- Joined: Sun Apr 15, 2012 1:17 am
- Location: USA
- Contact:
Re: Using Updatescreen in Game Loops (Game Academy)
I am a teacher and I they came about as a result of my classes. I wrote them to help my students learn game programming using LiveCode. They have fun creating their very own games while learning about programming and computer science. It has been effective in attracting more girls and minorities to further studies in computers.
They learn how to break big problems into solvable pieces, about logic, problem solving, creativity, patience, debugging many other life skills taught only in computer science.
They also produce some amazing games that are challenging yet fun to play.
Thanks for the complement and I hope they help you. I look forward to seeing some of your games.
Thanks,
Newbie4
They learn how to break big problems into solvable pieces, about logic, problem solving, creativity, patience, debugging many other life skills taught only in computer science.
They also produce some amazing games that are challenging yet fun to play.
Thanks for the complement and I hope they help you. I look forward to seeing some of your games.
Thanks,
Newbie4
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/
Re: Using Updatescreen in Game Loops (Game Academy)
I want to share my apps with you, and I would love to see what your students came up with. Max7@aol.com
Max
Great sentence:
They learn how to break big problems into solvable pieces, about logic, problem solving, creativity, patience, debugging many other life skills taught only in computer science.
Max
Great sentence:
They learn how to break big problems into solvable pieces, about logic, problem solving, creativity, patience, debugging many other life skills taught only in computer science.
-
- VIP Livecode Opensource Backer
- Posts: 327
- Joined: Sun Apr 15, 2012 1:17 am
- Location: USA
- Contact:
Re: Using Updatescreen in Game Loops (Game Academy)
You can download and try some of them here http://erhs.shaosean.tk. I will be putting up more next week that are even better. I am always finding more effective ways of presenting the material and teaching the concepts, so the games keep getting better. I try to keep the website updated but get behind uploading their work.
I am also working on teaching them to do mobile apps and doing standard computer programs ( calculating, working with text, files, functions, etc). Those can be accessed from here https://sites.google.com/a/pgcps.org/livecode/home
I welcome any suggestions, samples of code, ideas...
Thank you
Cyril Pruszko
I am also working on teaching them to do mobile apps and doing standard computer programs ( calculating, working with text, files, functions, etc). Those can be accessed from here https://sites.google.com/a/pgcps.org/livecode/home
I welcome any suggestions, samples of code, ideas...
Thank you
Cyril Pruszko
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/
Re: Using Updatescreen in Game Loops (Game Academy)
Great stuff, thanks for sharing. More stuff for me to read yay!