It seems to me that the only sounds that can be used are the ones that come with the app. Is this true? Or is there something I'm overlooking? Same thing with fonts, can new ones be added?
Just wondering,
Thanks,
Cubbarooney
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
It seems to me that the only sounds that can be used are the ones that come with the app. Is this true? Or is there something I'm overlooking? Same thing with fonts, can new ones be added?
Just wondering,
Thanks,
Cubbarooney
I was actually working on a flappy bird clone myself (also underwater)! It isn't as nice as yours though (besides, mine is much easier)!
Thanks for the great learning material
Cubbarooney
I have noticed a similar bug, albeit not quite the same. When the line starts with a tab (or space) and it extends beyond the screen, instead of the code appearing on the next line it just "disappears". If the line doesn't start with a tab, however, the next line feature works fine.
I think this is a problem with iOS 7 as I did not see this problem on iOS 6. I should point out I'm using the iPad2.
Thanks,
Cubbarooney
Howdy all! I'm working on getting used to the photos module, which is fairly simple. However, I have one small difficulty: how to use the photos in the scene module.
The basic function of the hypothetical program is it takes a picture and then starts a scene. In this scene is a layer (we'll call it [self.layer]). I want to then do [self.layer.image = picture], where [picture] is the photo I just created. Only problem is that [capture_image()] returns no string value.
I realize that photos use the PIL, something I know next to nothing (okay, perhaps nothing) about. Is there a way to name the picture?
Thanks,
Cubbarooney
Thanks omz!
By the way, this is why I love Python. It is so simple, yet is very adaptable.
Cubbarooney
You remade the forums just for me to come back? :P
It looks very nice and I sure hope the spammers stay away. Granted, shiny trinkets attracts thieves.
Well, got to go back to recreating all my programs. Sort of failed when I backed them up...
Cubbarooney
P.S. I really like the switch to markdown. Keeps things "fluid", so to speak.
I use a bluetooth keyboard (not a fan of touch-boards) to type on my iPad and I was wondering if I can use the keyboard as an input for Pythonista. For example, if I were to create a program that had a guy walking, I could press the left arrow to change his direction or the spacebar to jump (etc.).
I've read through the entire forum (at least the titles of the posts) and haven't found anything that 100% answers my question. It seems that it can't be done (I saw one article about the touch-board and a few posts mentioning bluetooth keyboards), but agian I'm not certain. Thanks for the help in advance,
Cubbarooney
As I mentioned before, I will not be on much for three or four months. I'll still be programming, just not on iOS. I'll be back soon though!
Thanks for all the tons of help you gave me,
Cubbarooney
Yay! That solved the problem of not able to add sounds :)
Now I need to make a space game for the sound Eliskan just downloaded... Hmmmm...
Cubbarooney
@Eliskan
To paraphrase a tutorial I once read, the parens of the print statement are not needed, but help prevent the print statement from getting confused.
Cubbarooney
I'm glad that I was not only understandable, but also I was right!
Since we're on the topic of thinking far ahead and I'm learning how to use the pickle module, would a save/load function be practical/added? If you press the save button, a function pickles all of the variables. The reverse happens when you press the load button. (I'm sure this is how saving works most of the time.) I've done something like that (need to shorten it) and the snake game uses it for the high score.
Happy coding,
Cubbarooney
Yes, I had noticed the graphical bug (I only saw it in the top right corner, but I didn't look much).i do know what it is like to dread a certain rewrite ("I need more ideas! Anything instead of shortening that code!!!"). I was planning on reading the tile mapping code in detail (I want to know how it is done) so I'll let you know if I find any short cuts!
As for the game storing units, wouldn't a tuple be good? Or is it list, I get it confused. Just make a class that creates a new list after each click (that way you can have multiple commands) and then have a command delete said list once the troops arrive at the given point. Or could you just have each unit that is selected store their own location data? as in, if I tell A, B, and D to go to point $, then each of them has their "GPS" set to point $. But if you then, mid trip, told C and D to go to point £, they would each set their own "GPS" to point £. I hope that makes sense...
Cubbarooney
Not sure why I never said this before, but....
Awesome!!!
Two things I've noticed about the program:
That being said, the programs are still amazingly awesome.
And some one said that python wasn't good for games (some article I read)!
Cubbarooney
@PyLot
Wow, thanks! that really helps keep things a bit more organized :)
I owe ya' one.
Cubbarooney
(Yikes, I ask a lot of questions!)
Let's pretend I was writing a code that used the scene module. This code had a list of pictures that were only used 1/10 of the time. Instead of having all of that code "cluttering up" my main code I would want it in a seperate file that could be called upon when needed. I've done stuff like this before ("execfile()"), but that was without the scene module. Would it be that the second file should be an entirely new class? Or would it be that it would be another MyScene class? Or am I completely missing the ball here and it is something very different? or is it simply not possible (if so, why)?
Cubbarooney
Oh goodie, I don't like asking stupid questions :P
And that is interesting. Can you do the following then?
<pre>from scene import *
from scene import image as i
from time import time, localtime as ti, loc
from other_module import functiona, functionb as ,b</pre>
The first two are simple, it basically redefines image. The third line does it in bulk while line imports two commands, but only shortens one of them. Which of these (besides line one...) work? I just realized I can check myself... So I will. In a moment. I'll post what I find when I have Internet again (couple hours, out of house).
Thanks,
Cubbarooney
Hit boxes. The bane of my existence (at the moment at least).
I'm referring to hit boxes as in a button. If you press the button, something happens. If you press anywhere other else on the screen however, nothing happens.
The way I figured out how to do this is to create a rectangle with many if statements.
(If this didn't make sense I'll provide an example).
This method, however, requires a lot of code. And I'm going to have five buttons at least. There has to be an easier way!
That is where you (yes, you on the other side of the screen) come in. If you know how, then I'd like to know.
Thanks in advance,
Cubbarooney
Didn't know that import worked with scripts too! This has many uses...
Thanks Eliskan! Helped a lot. Now have to twiddle with another idea, possibly fail, and then (if the previous step proves true) post question #11. :D
Cubbarooney
P.S. you did a good job explaining the method!
@Sebastian
Thanks for the simple code! That (combined with omz) really explained the hit box.
@omz
Thanks for the very detailed explanations! Cascade makes more sense now, as does hit boxes. I learned quite a lot today :)
@jose3f
I haven't looked at yours yet (only just finished supper), but I'll look at it right away! Then I'll comment again.
Cubbarooney
Thanks for your helpful (and speedy) reply! That being said, I'm still having some "slight" trouble... As I'm not using layers, I'm trying to use the "Cascade" method.
I think the root of my trouble stems from the inputs into the "Tile" class and then the "hit_test" function.
I'll walk through the following code so you can (hopefully) understand what is going on in my brain:
<pre> def hit_test(self, touch):
frame = Rect(self.x * tile_size + self.offset.x,
self.y * tile_size + self.offset.y,
tile_size, tile_size)
return touch.location in frame</pre>
So let me see...
Line 1) Basic enough. creates the function and has the inputs self and touch. Touch consists of touch.x and touch.y.
Line 2) creates the variable frame. QUESTION: is frame just the name you used, or does it have to be frame?
Frame represents a rectangle. the x value is (ignoring tile_size and self.offset.x/self.offset.y) self.x (which was defined in the initial setup. I'll go through that later), the y value is self.y, and then the width and height is tile_size (defined earlier).
Line 3) return (as a value) "touch.location in frame". So, in the variable that we created above is somewhere touch.location. But isn't it one of the inputs?
Now to the initial setup (which I probably should have done first):
<pre> def init(self, image, x, y):
self.offset = Point() # used for falling animation
self.selected = False
self.image = image
self.x, self.y = x, y</pre>
So now we have four inputs. self, image, x, and y. Only problem is, where do they come from? Also, it appears to me that "self.selected = False" and "self. image = image" aren't used in the "Tile" class (are they, perhaps, carried out of the class into the "Game" class?). Nonetheless, where does x and y come from?
Well, it seems to me that the input from the "main" code is as follows:
<pre>for i in xrange(cols * rows):
tile = Tile(images[randint(0, len(images)-1)], i % cols, i / cols)</pre>
I have no clue what that means... I take that back, I think I understand it a little. The "images[randint(0, len(images)-1)]" is the image input, "i%cols" is x, and "i/cols" is the y. I don't fully get the meaning of each though.
If I didn't make sense (or left something out) let me know and I'll clarify/modify the post. Thanks for dealing with rookies like me.
Cubbarooney