omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. Drizzel

    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.


    • Profile
    • Following 0
    • Followers 0
    • Topics 29
    • Posts 135
    • Best 14
    • Controversial 0
    • Groups 0

    Drizzel

    @Drizzel

    15
    Reputation
    2093
    Profile views
    135
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Drizzel Unfollow Follow

    Best posts made by Drizzel

    • RE: Flappy bird

      @Karina the issue lies in line 22.
      Since add_column is in the loop, it will get called plenty of times. This results in a lot of columns stacked on top of another, and it is very probable that at least once these columns has the maximum number boxes, and therefore the „smallest“ gap.
      Just remove one of the indents in line 22 to fix this.

      Btw, what @stephen said is certainly worth looking into, like just about any of his suggestions

      posted in Pythonista
      Drizzel
      Drizzel
    • RE: Help! I need help thinking of python projects I can do.

      @Bumbo-Cactoni I'm a bit late to the party, but you could always check out Cambidge IGCSE Computer Science past papers. Just search for them in your favourite search engine. They provide beginner level excercises and solutions, since the exams are aimed at students with 2 years of coding experience.
      Just be aware that for every year, there's one paper with a coding excercise (the one you want) and one paper with theory (boring).

      I had to pass this exam in 2018, just as an example
      There's more here.

      posted in Pythonista
      Drizzel
      Drizzel
    • RE: Flappy bird

      @stephen looking good! I always was a little too lazy to try them all out... and I’m not using scene much nowadays.

      posted in Pythonista
      Drizzel
      Drizzel
    • RE: Access TableViewCells

      @stephen That’s how I understood him. And it worked out really well, after some minor adaptions

      posted in Pythonista
      Drizzel
      Drizzel
    • haptic and vibration feedback

      I was just playing around, and thought this might be useful to others as well. So I signed up to GitHub. Feelback (didn't know how else to call it, I know it's a bit cringey) makes it fairly easy to get vibrations and haptic feedback, assuming your device has a haptic engine built in.

      The oldest supported iPhone is the 6s (mine), and it only works with a little workaround. I don't know which iPads work (my iPad mini 2 is just way too old), or if they have a haptic engine at all.

      Does anyone know if there are other SystemSounds than these? Because even this list doesn't include the ids for haptic feedback (1519, 1520, 1521) , so there may be more.

      posted in Pythonista
      Drizzel
      Drizzel
    • RE: Flappy bird

      @stephen thanks for the kind words, but some things are clumsy at best. Your summary is awesome, though. Although I am really glad that I can help here :) That way I can return at least a small amount of the support this community here has given me

      posted in Pythonista
      Drizzel
      Drizzel
    • RE: Flappy bird

      @Karina

      This is an old and sometimes very poorly written clone I did to learn about ai (flappy bird is an awesome game for basic artificial intelligence experiments). I didn’t bother about graphics, but maybe it’s helpful to you.

      Run this to play the game:

      from scene import *
      import sound
      import random
      import math
      import gameExtension as extension
      #import nnExtension as nn
      A = Action
      
      class MyScene (Scene):
      	
      	def setup(self):
      		self.background_color = 'beige'
      		self.gravity = Vector2(0, -self.size.y/1500)
      		self.birds = []
      
      		self.running = True
      		extension.setup_walls(self)
      		extension.update_walls(self)
      		
      		#self.birdCount = 1 #uncomment if using ai
      		
      		for x in range(self.birdCount):
      			extension.add_bird(self)
      		pass
      	
      	def did_change_size(self):
      		pass
      	
      	def update(self):
      		if self.running:
      			self.running = False
      			extension.update_walls(self)
      			
      			for bird in self.birds:
      				if bird.distance >= 10000: bird.dead = True
      				if not bird.dead:
      					self.running = True
      					extension.count_distance(self, bird)
      					extension.update_bird(self, bird)
      					bird.data = extension.get_data(self, bird)
      					
      					if bird.position.y-bird.size.y/2 <= 0 or bird.position.y+bird.size.y/2 >= self.size.y:
      						bird.color = 'red'
      						bird.dead = True
      						
      					for wall in self.walls:
      						if bird.frame.intersects(wall.frame):
      							bird.color = 'red'
      							bird.dead = True
      				else:
      					if bird.position.x + bird.size.x/2 >= 0:
      						bird.position = (bird.position.x - 1, bird.position.y)
      			
      			
      		
      	def touch_began(self, touch):
      		self.birds[0].up = True
      		pass
      	
      	def touch_moved(self, touch):
      		pass
      	
      	def touch_ended(self, touch):
      		pass
      
      if __name__ == '__main__':
      	run(MyScene(), PORTRAIT, show_fps=True)
      
      

      Save this in the same folder as the upper main code as gameExtension.py

      from scene import *
      import random
      
      def add_bird(self):
      	self.birds.append(ShapeNode(rect(0,0,10,10)))
      	bird = self.birds[len(self.birds)-1]
      	bird.color = 'black'
      	bird.size = (self.size.x/50, self.size.x/50)
      	bird.position = (self.size.x/4, self.size.y/2)
      	bird.z_position = 2
      	bird.dead = False
      	bird.distance = 0
      	bird.up = False
      	bird.max_fall_vel = Vector2(0, self.size.y/100)
      	bird.up_acc = Vector2(0, self.size.y/2)
      	bird.vel = Vector2(0, 0)
      	bird.acc = Vector2(0, 0)
      	bird.data = get_data(self, bird)
      	self.add_child(bird)
      	
      def setup_walls(self):
      	self.wall_distance = self.size.x/4
      	self.gap_size = self.size.y/6
      	self.wall_width = self.size.x/14
      	self.distance_to_next_wall = self.wall_distance + 1
      	self.walls = []
      	
      def count_distance(self, bird):
      	bird.distance = bird.distance + 1
      	
      def update_walls(self):
      	if self.distance_to_next_wall >= self.wall_distance:
      		self.distance_to_next_wall = 0
      		build_wall(self)
      	else: self.distance_to_next_wall = self.distance_to_next_wall+1
      		
      	removal = []
      	for x in range(len(self.walls)):
      		wall = self.walls[x]
      		wall.position = (wall.position.x - 1, wall.position.y)
      		
      		if wall.position.x + wall.size.x/2 < 0:
      			removal.append(x)
      	
      	for x in range(len(removal)):
      		wallIndex = removal[x]-x
      		wall = self.walls[wallIndex]
      		wall.remove_from_parent()
      		self.walls.pop(wallIndex)
      		
      def build_wall(self):
      	posY = random.randint(round(self.gap_size/2), round(self.size.y - self.gap_size/2)) #random position of gap
      	
      	self.walls.append(ShapeNode(rect(0,0,10,10))) #set up the upper wall
      	wall = self.walls[len(self.walls)-1]
      	wall.size = (self.wall_width, self.size.y - posY - self.gap_size/2)
      	wall.color = 'grey'
      	wall.position = (self.size.x + self.wall_width/2, self.size.y - wall.size.y/2)
      	wall.z_position =  1
      	self.add_child(wall)
      	
      	self.walls.append(ShapeNode(rect(0,0,10,10))) #set up the lower wall
      	wall = self.walls[len(self.walls)-1]
      	wall.size = (self.wall_width, posY - self.gap_size/2)
      	wall.color = 'grey'
      	wall.position = (self.size.x + self.wall_width/2, wall.size.y/2)
      	wall.z_position =  1
      	self.add_child(wall)
      	
      def update_bird(self, bird):
      	if bird.up:
      		bird.up = False
      		bird.acc = bird.up_acc
      	else: bird.acc = self.gravity
      		
      	bird.vel = bird.vel + bird.acc
      	if bird.vel[1] > bird.max_fall_vel[1]: bird.vel = bird.max_fall_vel
      	
      	
      	bird.position = bird.position + bird.vel
      	
      def get_data(self, bird):
      	data = []
      	for x in range(len(self.walls)):
      		wall = self.walls[x]
      		if wall.position.x + wall.size.x/2 >= bird.position.x - bird.size.x/2:
      			y_to_gap = (wall.position.x - wall.size.x/2) - (bird.position.x + bird.size.x/2)
      			if y_to_gap < 0: y_to_gap = 0
      			data.append(y_to_gap)
      			x_to_upper_wall = (wall.position.y - wall.size.y/2) - (bird.position.y + bird.size.y/2)
      			data.append(x_to_upper_wall)
      			wall = self.walls[x+1]
      			x_to_lower_wall = (wall.position.y + wall.size.y/2) - (bird.position.y - bird.size.y/2)
      			data.append(x_to_lower_wall)
      			break
      	distance_to_top = self.size.y - bird.position.y + bird.size.y/2
      	data.append(distance_to_top)
      	distance_to_bottom = bird.position.y - bird.size.y/2
      	data.append(distance_to_bottom)
      	velocity = bird.vel[1]
      	data.append(velocity)
      	return data
      
      posted in Pythonista
      Drizzel
      Drizzel
    • RE: [RPG Update] - For those following along

      Im not even positive anyone is even wanting to follow the progress of this lol but just in case one person is here is change log 1 lol

      Don’t sell yourself short😂 it’s always interesting to know what others are working on

      posted in Pythonista
      Drizzel
      Drizzel
    • RE: Pure Python gestures

      @stephen True, I corrected it :) The code was a bit rushed 🤷‍♂️

      posted in Pythonista
      Drizzel
      Drizzel
    • RE: need some criticized input please.

      As far as I've understood, you want some design feedback on these graphics, right?
      Did you design these graphics yourself? If not, this might be a bit too detailed, sry

      General feedback

      • all designs are really well recognisable
      • every color scheme is good
      • not a single flaw in the perspectives
      • you repeat that they're icons. If they're going to be shown in a small size, they might be too detailed

      Rune Stone

      • I love the design
      • if you want to minimalise it, get rid of the grey scratches (not the black cracks)

      Common Sword

      • I dunno, but I'd assume that a common sword would neither have a gem inlay nor a fancy hilt and guard (after all it's a golden color)
      • if you want to minimalise it, get rid of the scratches.
      • the dents look awesome

      Short bow

      • What you show here is a long bow, a short bow usually has a recurve in order to deliver greater power (check out recurve bows)
      • the wrapping fits the sword handle, nice touch

      Attributes:

      • Amazing looking
      • already quite minimal, since there's no scratches
      • absolutely no more improvement suggestions

      spell book icon

      • looks great
      • maybe a bit to detailed (depends on how large it is when shown in your rpg)
      • maybe add some shadows around the rune stones to add depth, they are weirdly flat right now

      barrel

      • good color scheme, but I'd darken the wood colors to a walnut color, looks more aged interesting

      mana potion

      • darken the cork, otherwise the design is great
      • no need to minimalise

      health icon

      • too detailed, get rid of the "HP"
      • the ouch and scratches in the top left are a nice touch.
        *maybe replace the patches with the scratches from the top left, and leave the top left empty

      ruby garnets

      • look amazing, perspective is well done
      posted in Pythonista
      Drizzel
      Drizzel

    Latest posts made by Drizzel

    • RE: M1 MacBook and Pythonista

      @mikael awesome, thanks

      posted in Pythonista
      Drizzel
      Drizzel
    • RE: M1 MacBook and Pythonista

      That is music to my ears! My iPad Mini 2 broke down quite a while ago, and I also need a new laptop. Might just as well beat two birds with one stone. Btw, I finished school and study Mechatronics now :D

      Any idea if ui applications work?

      posted in Pythonista
      Drizzel
      Drizzel
    • RE: Help! I need help thinking of python projects I can do.

      @Bumbo-Cactoni I'm a bit late to the party, but you could always check out Cambidge IGCSE Computer Science past papers. Just search for them in your favourite search engine. They provide beginner level excercises and solutions, since the exams are aimed at students with 2 years of coding experience.
      Just be aware that for every year, there's one paper with a coding excercise (the one you want) and one paper with theory (boring).

      I had to pass this exam in 2018, just as an example
      There's more here.

      posted in Pythonista
      Drizzel
      Drizzel
    • RE: What’s an anonymous label?

      @mikael said:

      Could you try to strip down (a copy of) your code

      Of course, no problem. It might take me one or two days, because I have exams coming up

      posted in Pythonista
      Drizzel
      Drizzel
    • What’s an anonymous label?

      Since I have absolutely no clue how I caused this error, the following will be rather unspecific, my apologies

      So I have a very modified table view. Sometimes, when I remove some cell with the delete_rows() function, and then scroll down to see cells that weren’t displayed when deleting, some of these newly presented cells are totally blank. They simply are a white, empty area. I can tap them normally, and the proper functions are called. When I long press them (thanks to @mikael and his gestures script) I get the following error:

      Traceback (most recent call last):
        File "/private/var/mobile/Containers/Shared/AppGroup/D1D9102B-9BBB-4003-A835-39FDFDA39AB1/Pythonista3/Documents/v9/play_view.py", line 50, in skip_action
          self.player.finished_handler()
        File "/private/var/mobile/Containers/Shared/AppGroup/D1D9102B-9BBB-4003-A835-39FDFDA39AB1/Pythonista3/Documents/v9/audio_manager.py", line 72, in finished_handler
          section = prev_cell.section
      AttributeError: '_anonymous_label' object has no attribute 'section'
      

      So what is an _anonymous_label, and how did I cause this?

      I’m really sorry that I’m so unspecific, I simply have no idea how my (pretty long) code got to this

      posted in Pythonista
      Drizzel
      Drizzel
    • RE: Flappy bird

      @Karina Yeah, we have a little “chicken house” and I wrote a script that opens and closes the door by turning on and off a motor. But that’s not the point :) I just needed an example to better illustrate the uses of threads

      posted in Pythonista
      Drizzel
      Drizzel
    • RE: Flappy bird

      @Karina Now yes, threads may not always speed up your program. But they can keep your program responsive even though there’s some time consuming task being done. I also sometimes use them to constantly check if a variable changed, and then trigger a function. (There’s better ways to do that. But hey, I’m learning too.)

      Even though this is in no way specific to Pythonista, let’s take a slight detour. Some time ago, I built a door manager for the chicken pen of my family (yeah, it’s a bit unusual). It opens and closes the door at given times, but also constantly checks a button and email for a manual overrides. Since the button needs to be checked every 0.1 seconds, but checking the email takes about 4 seconds (establishing a connection to the google servers takes some time), the button wouldn’t be checked while the code is trying to get the new email. This is solved with threads, so they get checked in parallel, not after each
      Therefore the button stays responsive, even though checking mails uses up a lot of time

      posted in Pythonista
      Drizzel
      Drizzel
    • RE: Flappy bird

      @Karina said:

      I began to read about threads and sometimes don't understand what about this all, but in general understand. And for what here to use them? It encreases the speed of smth?

      I certainly don’t know everything about threads either, but here’s my understanding of them.

      The basics:

      • I think of threads like... well threads, as in strings or a thin rope. And when you open a thread, the code in this thread is run separated to other threads.

      • Thus Threads allow for separate codes to run “at the same time” (this technically isn’t possible, and is done through some tricks so that it appears so. Thus the quotation mark. But I’m not here to confuse you, so let’s go on)

      • Therefore you can have one section of code that (for example) has a time.sleep(100000) in it, and a thread that prints stuff in an infinite loop. Since they run in different threads, your code will still print stuff, even though there’s a stupidly long sleep statement in it

      Edit If you want some coding examples, I can write you some with comments

      posted in Pythonista
      Drizzel
      Drizzel
    • RE: Flappy bird

      @stephen looking good! I always was a little too lazy to try them all out... and I’m not using scene much nowadays.

      posted in Pythonista
      Drizzel
      Drizzel
    • RE: Flappy bird

      @Karina I think you got me mixed up with @stephen :) And yes, I do prefer to fix the node‘s position manually.

      My version of flappy bird I posted here some days ago is a good example. I used basic physics formulas to give the bird an acceleration, and then use that to calculate the bird‘s speed and thus position at a given time. Then adjusting the gravity and weight parameters made the motion feel “just right” (in my opinion).

      Technical stuff aside, I just do it for greater control, so I can get the feeling of motions right.

      posted in Pythonista
      Drizzel
      Drizzel