Tuesday, February 14, 2023

US Inflation_January

 L’inflation annuelle a ralenti à 6,4 % aux États-Unis le mois dernier | Radio-Canada.ca

                                             *     *     *

Discussion of C-22 in the Senate, Feb 14:

https://sencanada.ca/en/content/sen/chamber/441/debates/100db_2023-02-14-e#49

Valentine's


 Exceptionally, daughter Lyse is with me on Valentine's Day (She's off for

her annual vacation trip tomorrow). Made a new recipe: Southern egg pie

with nutmeg. Looks yummy.


Never had pie for breakfast... before. 😉

HAPPY VALENTINE'S DAY TO ALL!

                                     *     *     *

Bill C-22 is on the Orders of the Day, for the Senate:




Monday, February 13, 2023

Second Reading

 



One week to go in February and Senate debate on C-22, second reading,  began debate 
on Feb 9, only to get postponed. One may well wonder if it has any chance of getting
through this month.

I find it somewhat tragic that this bill keeps getting marooned over conceptual
issues: it is meant to help many who are seriously disabled or chronically ill;
but I also can see where the problem stems from.

The CDB is presented as modelled on the GIS which tops up benefits for
the elderly. The latter is at  federal level program, and  pays out benefits
on a totally similar formula for all, eveywhere in Canada. The talk around CDB
is that it tops up provincial aid, which varies with the means and delivery models
of the different jurisdictions. What ‽

One ends up with amenedments to protect recipients against clawback, and concerns
that federal money won't get lost in provincial administration. Report back to us!! Can 
this ever be a reasonable and comprehensible program.

Heuristically at least, I would be tempted to define a core guaranteed amount. 
From there, one could add a variable amount for disability expenses. by
category of client, not by region.  I would let provincial payments - or work income - 
make up the difference. Provinces would remain free to include payments also given to
the general population. 

This shifts things to the Feds; but provinces are already complaining they cannot
manage care for the elderly and health costs, all at once. Clawback is inevitable, but
only for those who make fair amounts of money from work. That's how OAS/GIS works. 
Only here, core and disability expenses are inviolate.

Just a suggestion...

                                                     *     *     *

The recent earthquakes in Turkey have made me curious. What, geologically, is happening

in that region. Turns out that three tectonic plates or pieces meet in SouthEast Trurkey. 

Map below. The first event, 7.5 on the Richter scale, was on a 'senestre' strike-split fault

between the Anatolian and Arabian plates.. This means that, standing on either side of the 

fault, the opposite block moved left.


                                                         

                                               Wikipedia


                                                                            


I could not help but notice that Ukraine is North of Turkey, on the 

other side of the Black Sea. A year of constant bombings could not have been

a good thing, geologically speaking!

                                                                      


Sunday, February 12, 2023

Relative

 Below, a couple having a hard time of it. It takes them ever longer to understand 

each other:

                                                             



From the very nice explanation of relativity:

https://www.science.org.au/curious/space-time/gravity#:~:text=Gravity%20bends%20light&text=Light%20travels%20through%20spacetime%2C%20which,of%20light%20caused%20by%20gravity%20.


With respect to gravity, everyone agress that the clock near a massive object is slower.

                                                                          


                                              Wikipedia

GPS systems have to take both phenomena into account.


                                                                *     *     *



Friday, February 10, 2023

Cantaloupe

Time for me to let go of bananas; they were great during the darkest moment

of winter, and I might need them again. For the moment, am looking to the lighter

alternative, cantaloupe. 


A cantaloupe is a  large fruit for one person to down, but I mince mine and store

the pieces in the freezer. I am then free to take out a bit, au besoin.


Really refreshing, too!

Bellow, hot cereal with fruit, sweetened with Dulce de Leche.


Bowl of canned and fresh fruit, with an ice cube.
                
            
The frozen goods. (My plastic container cracked, and needs to be replaced‽)


Before and After

 I have been asked about removing things in pygame. One uses the built-in Sprite class.

Below, from an geeksforgeeks example:

https://www.geeksforgeeks.org/pygame-creating-sprites/


mport pygame
import random

# GLOBAL VARIABLES ARE CAPITALIZED
COLOR = (255, 100, 98)
SURFACE_COLOR = (167, 255, 100)
WIDTH = 500
HEIGHT = 500

# Creation of Object class. Where object color is the same as surface color,
# the pixels will be transparent
class Sprite(pygame.sprite.Sprite):
def __init__(self, color, height, width):
super().__init__()

self.image = pygame.Surface([width, height])
self.image.fill(SURFACE_COLOR)
self.image.set_colorkey(COLOR)

pygame.draw.rect(self.image, color, pygame.Rect(0, 0, width, height))

self.rect = self.image.get_rect()

#Starting an actual game. It is a good idea to call quit on pygame before exit on the OS.
pygame.init()

RED = (255, 0, 0)

size = (WIDTH, HEIGHT)
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Creating Sprite")

all_sprites_list = pygame.sprite.Group()

object_ = Sprite(RED, 20, 30)
object_.rect.x = 200
object_.rect.y = 300

all_sprites_list.add(object_)

exit = True
clock = pygame.time.Clock()

#Removing an individual sprite from its sprite group removes it from the game.
while exit:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
all_sprites_list.remove(object_)

all_sprites_list.update()
screen.fill(SURFACE_COLOR)
all_sprites_list.draw(screen)
pygame.display.flip()
clock.tick(60)

pygame.quit()
Before clicking any keys:

                                                                      

After clicking the Left Key:

                                                                                

                                                          *     *     *

Pygame is decidedly OOP, and works with classes. Game objects are class instances.

Below, two examples of objects made to disappear on terms defined by their respective

class constructors. With the explicitly named 'kill' funcrtion. Remove is used for removal

from one group; kill for removal from all groups.


The first, on condition that the rectangle reaches the bottom of the window. The second,

on a timer.


Playable

I've removed the border: it's playable.


import random
import time
import pygame
import os
from os import remove
pygame.font.init()
pygame.mixer.init()

WIDTH, HEIGHT = 900, 500
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("First Game!")

WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
YELLOW = (255, 255, 0)

HEALTH_FONT = pygame.font.SysFont('comicsans', 40)
WINNER_FONT = pygame.font.SysFont('comicsans', 100)

FPS = 60
VEL = 5
BULLET_VEL = 7
MAX_BULLETS = 3
SPACESHIP_WIDTH, SPACESHIP_HEIGHT = 45, 45

BALLOON_WIDTH, BALLOON_HEIGHT = 60, 60
YELLOW_HIT = pygame.USEREVENT + 1
RED_HIT = pygame.USEREVENT + 2
BALLOON_HIT_Y = pygame.USEREVENT + 3
BALLOON_HIT_R = pygame.USEREVENT + 4
YELLOW_SPACESHIP_IMAGE = pygame.image.load(
os.path.join('Assets', 'spaceship_yellow.png'))
YELLOW_SPACESHIP = pygame.transform.rotate(pygame.transform.scale(
YELLOW_SPACESHIP_IMAGE, (SPACESHIP_WIDTH, SPACESHIP_HEIGHT)), 90)

RED_SPACESHIP_IMAGE = pygame.image.load(
os.path.join('Assets', 'spaceship_red.png'))
RED_SPACESHIP = pygame.transform.rotate(pygame.transform.scale(
RED_SPACESHIP_IMAGE, (SPACESHIP_WIDTH, SPACESHIP_HEIGHT)), 270)

SPACE = pygame.transform.scale(pygame.image.load(
os.path.join('Assets', 'space.png')), (WIDTH, HEIGHT))

BALLOON = pygame.image.load('WBalloon.gif')
BALLOON_RECT = BALLOON.get_rect()

balloon = pygame.sprite.Sprite()
obstacles = pygame.sprite.Group()
obstacles.add(balloon)
def draw_window(red, yellow, red_bullets, yellow_bullets, red_health,
yellow_health, balloon):
WIN.blit(SPACE, (0, 0))


red_health_text = HEALTH_FONT.render(
"Health: " + str(red_health), 1, WHITE)
yellow_health_text = HEALTH_FONT.render(
"Health: " + str(yellow_health), 1, WHITE)
WIN.blit(red_health_text, (WIDTH - red_health_text.get_width() - 10, 10))
WIN.blit(yellow_health_text, (10, 10))

WIN.blit(YELLOW_SPACESHIP, (yellow.x, yellow.y))
WIN.blit(RED_SPACESHIP, (red.x, red.y))


WIN.blit(BALLOON, (balloon.x, balloon.y))


for bullet in red_bullets:
pygame.draw.rect(WIN, RED, bullet)

for bullet in yellow_bullets:
pygame.draw.rect(WIN, YELLOW, bullet)



pygame.display.update()


def yellow_handle_movement(keys_pressed, yellow):
if keys_pressed[pygame.K_a] and yellow.x - VEL > 0: # LEFT
yellow.x -= VEL
if keys_pressed[pygame.K_d] and yellow.x + VEL + yellow.width < 900: # RIGHT
yellow.x += VEL
if keys_pressed[pygame.K_w] and yellow.y - VEL > 0: # UP
yellow.y -= VEL
if keys_pressed[pygame.K_s] and yellow.y + VEL + yellow.height \
< HEIGHT - 15: # DOWN
yellow.y += VEL


def red_handle_movement(keys_pressed, red):
if keys_pressed[pygame.K_LEFT] and red.x - VEL > 0: # LEFT
red.x -= VEL
if keys_pressed[pygame.K_RIGHT] and red.x + VEL + red.width < 900: # RIGHT
red.x += VEL
if keys_pressed[pygame.K_UP] and red.y - VEL > 0: # UP
red.y -= VEL
if keys_pressed[pygame.K_DOWN] and red.y + VEL + red.height < HEIGHT - 15: # DOWN
red.y += VEL


def handle_bullets(yellow_bullets, red_bullets, yellow, red, balloon,
yellow_health, red_health):
for bullet in yellow_bullets:
bullet.x += BULLET_VEL
if red.colliderect(bullet):
pygame.event.post(pygame.event.Event(RED_HIT))
yellow_bullets.remove(bullet)
elif balloon.colliderect(bullet):
pygame.event.post(pygame.event.Event(BALLOON_HIT_Y))
yellow_bullets.remove(bullet)

elif bullet.x > WIDTH:
yellow_bullets.remove(bullet)

for bullet in red_bullets:
bullet.x -= BULLET_VEL
if yellow.colliderect(bullet):
pygame.event.post(pygame.event.Event(YELLOW_HIT))
red_bullets.remove(bullet)

elif balloon.colliderect(bullet):
pygame.event.post(pygame.event.Event(BALLOON_HIT_R))
red_bullets.remove(bullet)



elif bullet.x < 0:
red_bullets.remove(bullet)


def draw_winner(text):
draw_text = WINNER_FONT.render(text, 1, WHITE)
WIN.blit(draw_text, (WIDTH/2 - draw_text.get_width() /
2, HEIGHT/2 - draw_text.get_height()/2))
pygame.display.update()
pygame.time.delay(5000)


def main():
BALLOON_X = random.randrange(100, 800, 10)
BALLOON_Y = random.randrange(30, 470, 10)
red = pygame.Rect(700, 300, SPACESHIP_WIDTH, SPACESHIP_HEIGHT)
yellow = pygame.Rect(100, 300, SPACESHIP_WIDTH, SPACESHIP_HEIGHT)
balloon = pygame.Rect(BALLOON_X, BALLOON_Y, BALLOON_WIDTH,
BALLOON_HEIGHT)

red_bullets = []
yellow_bullets = []


red_health = 10
yellow_health = 10

clock = pygame.time.Clock()
run = True
while run:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.quit()

if event.type == pygame.KEYDOWN:

if event.key == pygame.K_z and len(yellow_bullets) \
< MAX_BULLETS:
bullet = pygame.Rect(
yellow.x + yellow.width, yellow.y +
yellow.height//2 - 2, 10, 5)
yellow_bullets.append(bullet)
#BULLET_FIRE_SOUND.play()
print("Bullet_yellow", time.time())

if event.key == pygame.K_SLASH and len(red_bullets) <\
MAX_BULLETS:
bullet = pygame.Rect(
red.x, red.y + red.height//2 - 2, 10, 5)
red_bullets.append(bullet)
#BULLET_FIRE_SOUND.play()
print("Bullet_red", time.time())


if event.type == RED_HIT:
red_health -= 1
#BULLET_HIT_SOUND.play()

if event.type == YELLOW_HIT:
yellow_health -= 1
#BULLET_HIT_SOUND.play()

if event.type == BALLOON_HIT_Y:
yellow_health -= 1


if event.type == BALLOON_HIT_R:
red_health -= 1


winner_text = ""
if red_health <= 0:
winner_text = "Yellow Wins!"

if yellow_health <= 0:
winner_text = "Red Wins!"

if winner_text != "":
draw_winner(winner_text)
break

keys_pressed = pygame.key.get_pressed()
yellow_handle_movement(keys_pressed, yellow)
red_handle_movement(keys_pressed, red)

handle_bullets(yellow_bullets, red_bullets, yellow, red, balloon,
yellow_health,
red_health)

draw_window(red, yellow, red_bullets, yellow_bullets,
red_health, yellow_health, balloon)



main()


if __name__ == "__main__":
main()

An alternative might be to keep the border, and have the balloon saunter across the screen.

It works for me, but even at 1 pixel per frame it is fast. Pygame doen't respond to floats so I ended up 

halving the FPS on the game.
  
Under main:
                                                                          
  
At the top, with the global variables: