Archiverse Internet Archive
投稿のみ 投稿と返信
前のページ(最近)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
次のページ(過去)
返信[8]
親投稿
Stewart segludian1
Now we need Create_Shovel to make a shovel projectile for us. I have SPVAR for x, y, heading, and speed. X, and Y may be redundant but I don't think SPOFS keeps track of position with floating point precision and I don't want cumulative error. Note it too registers a callback to update the shovel.
0そうだね
プレイ済み
返信[7]
親投稿
Stewart segludian1
Next up is the create hero function (the rotating knight). He has one spvar at index 0 to keep track of how many milliseconds remaining to wait before he can fire off a shovel again. Note the SPFUNC call that says what to call to update him each frame.
0そうだね
プレイ済み
返信[6]
親投稿
Stewart segludian1
Code part 1. Here we allocate variables call a function to create the player sprite, and enter the main game loop. I do have a few extras in there to give us time based movement so things run the same on old vs new 3ds. Although that really shouldn't be a problem for this example. CALL SPRITE calls all the registered sprite functions.
0そうだね
プレイ済み
返信[5]
親投稿
Stewart segludian1
You want something like the attached picture, right? What you need to do is create and update a sprite for each projectile. One way to do that would be to make a bunch of arrays, put all the data for each sprite into the arrays then update them a little at a time in the main game loop. Another way to do it is to use SPVAR to store the data, then have a SPFUNC and CALL SPRITE update it each frame.
0そうだね
プレイ済み
返信[26]
親投稿
Stewart segludian1
From an array instead. If your game generated a bunch of enemies over time it would likewise be good to put them in an array to loop over to update and such. Unfortunately we don't have user defined types in smilebasic so we often have to make a bunch of arrays to keep track of things with multiple fields that may have different data types. Hope that all makes sense.
0そうだね
プレイ済み
返信[25]
親投稿
Stewart segludian1
characters and loop through that to see if a guess is a repeat. You could use a sting for that too, but a string in SmileBasic is really just a special kind of character array. Finally in guess the number you may want to save the guesses and print them out. That is easier to do if you save them in an array then if you have a bunch of guess_1 through guess_10 variables. You could just push and pop
0そうだね
プレイ済み
返信[24]
親投稿
Stewart segludian1
write less and easier to follow code. Just think how bad it would be if you were doing something like checkers on a 8 by 8 grid without an array. Lets look at the other examples I said you should try. In hangman you want to keep track of what letters have been guessed already. You could have 26 variables a_guessed, b_guessed, through z_guessed and so on, or you could have an array of guessed
0そうだね
プレイ済み
返信[23]
親投稿
Stewart segludian1
and another for columns for i = 0 to 2 if board[i, 0] ==board[i, 1] and board[i, 1] ==board[i, 2] and board[i, 0] != blank then 'we have a match endif next i for example. If you don't have arrays you will need to code that check three times since each square is its own variable and has different names. Triple the work. Arrays make the code easier to read understand and maintain since you
0そうだね
プレイ済み
返信[22]
親投稿
Stewart segludian1
How will you keep tack of the game board? Without an array you would have to have 9 variables Board1 to Board9, or maybe Board11 to Board33 if you want to have implied rows and columns. With arrays you could just declare Board[9], or perhaps better Board[3,3]. Now lets say you want to check for three in a row horizontally or vertically. With arrays you can do two for loops one that looks at rows
0そうだね
プレイ済み
返信[21]
親投稿
Stewart segludian1
Arrays are important. You will want one in SmileBasic whenever you are working with a list or grid of data. Or whenever you have a lot of something and a way to access it is more important than an individual name. Let's look at tic tac toe (or noughts and crosses if you prefer). You have a 3 by 3 grid where players take alternating turns placing an X or an O.
0そうだね
プレイ済み
返信[2]
親投稿
Stewart segludian1
Here is the help screen.
1そうだね
プレイ済み
返信[1]
親投稿
Stewart segludian1
Sorry, but the key is now: K2KYJCS I added birds flying left and right and a bottom help screen.
1そうだね
プレイ済み
プレイ日記
Stewart segludian1
Made some rushed improvements and submitted it to the contest (may have been too slow) even though it doesn't fit the theme. New key is EKE8V4CS. Improvements are coins you must collect before the door is revealed and Bats that impede your progress.
3そうだね
プレイ済み
返信[7]
親投稿
Stewart segludian1
Thanks, the download key is currently: ARR3V23E.
0そうだね
プレイ済み
プレイ日記
Stewart segludian1
This is my simplified platformer "Find the Exit". The key is: ARR3V23E. I took out scrolling, and time based movement. Hopefully it is easier to understand. Bug reports are welcome. See if you can make new levels!
3そうだね
プレイ済み
返信[5]
親投稿
Stewart segludian1
If it isn't working we may be able to diagnose the problem if you post a screen shot of the code in question. Option Strict, and adding data type postfixes are an ounce of prevention versus a pound of cure type of thing. They can head off a lot of very hard to debug problems ahead of time. It does take little longer, but I think it is worth it and I recommend it. It has saved me plenty of times.
1そうだね
プレイ済み
返信[2]
親投稿
Stewart segludian1
You don't want to create 24 FOR loops. Instead you want to make a nested FOR loop. Or in other words you have a FOR loop with another FOR loop inside of it. FOR Y = 1 TO 15 FOR X = 1 TO 25 'Code to set up a sprite NEXT X NEXT Y An example is attached. Let me know if you have any problems.
0そうだね
プレイ済み
返信[19]
親投稿
Stewart segludian1
That being said, if you are having problems with fundamentals like PRINT, you shouldn't be making sprite based games yet. Move on to those after you have things like: guess the number, hangman, and tic tac toe working. Oh, and INC is for increment, and DEC is for decrement basically adding or subtacting 1 from a number. If you have more questions feel free to ask. It isn't rude to ask.
0そうだね
プレイ済み
返信[18]
親投稿
Stewart segludian1
You keep everything moving independently with the game loop. You have a loop that runs over and over. Each frame is 1/60th of a second (hopefully) so you need to figure out how much and where things moved since the last frame. Normally you will keep track of your game world object in an array and loop over them in your game loop applying update logic for each one. See example on previous post.
0そうだね
プレイ済み
返信[17]
親投稿
Stewart segludian1
You only get 512 sprites active at a time between both screens. You can however dispose of a sprite and make a new one. It sounds like you are having problems with simulation and the game loop. Sprites aren't going to bump into walls or land on platforms unless you make them do so. You have to simulate the rules and physics of you game world (it is not as bad as that sounds -- mostly).
0そうだね
プレイ済み