Main content
Computer programming
What are scenes?
Many games and visualizations have what we call "scenes", and they need some way of managing those "scenes." What do I mean by scenes?
Take for example, Balloon Popper 2. It has four scenes:
| A start scene |
|
| A how-to-play scene |
|
| A playing scene |
|
| A game over scene |
|
Most games have those scenes, in fact. Each scene is a distinct state of the program that displays different information, and there is some way for the user to get from one scene to the next. Maybe it's a simple mouse click or key press, or maybe it's selecting a scene from a menu.
Once you've realized that you need something like scenes for your program, you'll have to decide how to program them. Like many things in programming, there are many ways to do that, but we'll hopefully give you a few ideas.
Want to join the conversation?
- I'm surprised to see that your "cursive" font (which is the font used on the title screen for the words "Balloon Popper") renders completely differently from mine. Mine looks more like balloons. I would have thought that the createFont() function was uniform for KA, but I guess it's browser-specific? Or is that a bug? I wonder what browser that was rendered in.(276 votes)
- "cursive" can be different for different browsers
It's one of many generic fonts that browsers are required to have. Others include serif, sans-serif, fantasy and monospace.
Browsers can vary in what font they pick for these but they should be similar.
For a real example of this go to this program[1] and look at the snapshots for the spinoffs. There are at least 3 different fonts visible for "cursive" but they're all the "cursive" font for the user's respective browser.
[1] https://www.khanacademy.org/cs/Fonts/6070307606495232
Hope this helped(232 votes)
- How do I make a game that plays with keys?(53 votes)
- You have to use this code:
if (keyIsPressed && keyCode = DOWN) {
yPos -= 1;
}
Then you do that with all of them except with different keycodes for different arrow keys.(14 votes)
- How do I actually use Processing.js? I felt like I learned a lot in Intro to JS but, apparently, you can't just use this like JavaScript. The gobbledygook at processingjs.org tells me I need to make a "pde" file but doesn't tell me how to do that and tells me I need a "sketch file" but gives me no information about those. Intro to JS didn't mention any of this, either. Everyone I email points me to the same QuickStart gobbledygook page. Can anyone please tell me what the prerequisites are to actually use ProcessingJS? Don't you think these questions should be answered in the Intro course?(33 votes)
- how to make a game an easy way(7 votes)
- All the things that are worth building require work and dedication. It's not like you can randomly press keys and have the Minecraft game as a result.
If you want to put in the time to make your own game, I would love to play it. If not, well, I'm just glad there are other people that do.(43 votes)
- How do you make scene transition to a previous scene?
I'm trying to make a game where when you die there's a "Retry" button that takes you back, but it can't, because the scene is called for before it's created. I could provide the code that I used, if necessary.
basically, it's like this.
var drawscene1 = function(){
This is the Game Over scene
mouseClicked = function(){
drawscene2();
};
var drawscene2 = function (){
This is the game scene
if (health<0){
drawscene1();
}
Thanks in advance!(18 votes) - how do you make a cursor disappear on KA?(9 votes)
- Invoke
cursor("none");
to remove the cursor.(9 votes)
- All these messages was long time ago they are probably parents already I’m left behind 😭😭😭(9 votes)
- One was my cousin who now has 2 kids(3 votes)
- is throw a command? If it is how do I use it?(5 votes)
- Yes, throw is a command. In khan academy's processing.js script, you can call Oh Noes with the throw command. For example, you can write this:
throw{
message:("This is a throw command."),
row:(5)
};(7 votes)
- how do you make a simple game(6 votes)
- i just skip the video(0 votes)
- where can i find tutorials on making games like this?(0 votes)
- In order to create things like this, you start in intro to J.S. and learn all the skills you need to make fun projects like this.(12 votes)