Discuss Scratch

scott170
Scratcher
84 posts

Python programming language

cinnamvn wrote:

i work part time as a tutor, and i’m currently teaching computer science to a few of my students ^^ python is the main programming language i use, as well as scratch for the more younger ones. i’m /attempting/ to make a mystery game right now :>
Nice! I help run cs courses through a club in my local area
the link is on my about me
-EmeraldThunder-
Scratcher
1000+ posts

Python programming language

cinnamvn wrote:

i work part time as a tutor, and i’m currently teaching computer science to a few of my students ^^ python is the main programming language i use, as well as scratch for the more younger ones. i’m /attempting/ to make a mystery game right now :>
Cool, I wish you and your students well for the course.

Nothing here.
scott170
Scratcher
84 posts

Python programming language

anybody make an cool programs?
mumu245
Scratcher
1000+ posts

Python programming language

scott170 wrote:

anybody make an cool programs?
Yes.

select this text then press Ctrl+Shift+Down to read more
scott170
Scratcher
84 posts

Python programming language

what would be some ways you would use a walrus operator? also why is this forum dead now
Wei-ern_520
Scratcher
500+ posts

Python programming language

scott170 wrote:

what would be some ways you would use a walrus operator? also why is this forum dead now
1. Not much scenarios, since it is not very useful (correct me if I’m wrong)

2. Probably not many know about this forum or just not many people do python here. (correct me if I’m wrong again).

3. Just asking, what is everyone working on?

4. Who here uses pygame most of the time (and when I meant that I meant using pygame more than any libraries ever)

Last edited by Wei-ern_520 (Oct. 14, 2021 09:17:17)


Please consider checking out my suggestion ->here<-.

Hello, I’m Wei-ern_520, and I will randomly appear in your room! Just kidding, I make rpg engines.

I have no custom pfp, not because I don't know how to make one. I just don't know what suits me best, and I'm just too lazy and prefer sticking to simplicity. Or at least so. I also have the need to trip people with my profile picture. Just wait till it happens.

Fun fact: you don't clean your mess, you move it somewhere else. (Source: somewhere)

Also: Ooh, look at the cheese!
Sid72020123
Scratcher
500+ posts

Python programming language

Wei-ern_520 wrote:

scott170 wrote:

what would be some ways you would use a walrus operator? also why is this forum dead now
1. Not much scenarios, since it is not very useful (correct me if I’m wrong)

2. Probably not many know about this forum or just not many people do python here. (correct me if I’m wrong again).

3. Just asking, what is everyone working on?

4. Who here uses pygame most of the time (and when I meant that I meant using pygame more than any libraries ever)

I am working on a python program that can connect the cloud variables in Python!

Hello!
Wei-ern_520
Scratcher
500+ posts

Python programming language

Sid72020123 wrote:

Wei-ern_520 wrote:

scott170 wrote:

what would be some ways you would use a walrus operator? also why is this forum dead now
Blah blah blah

I am working on a python program that can connect the cloud variables in Python!
Sounds kewl! (cool)

Last edited by Wei-ern_520 (Oct. 14, 2021 11:24:50)


Please consider checking out my suggestion ->here<-.

Hello, I’m Wei-ern_520, and I will randomly appear in your room! Just kidding, I make rpg engines.

I have no custom pfp, not because I don't know how to make one. I just don't know what suits me best, and I'm just too lazy and prefer sticking to simplicity. Or at least so. I also have the need to trip people with my profile picture. Just wait till it happens.

Fun fact: you don't clean your mess, you move it somewhere else. (Source: somewhere)

Also: Ooh, look at the cheese!
Sid72020123
Scratcher
500+ posts

Python programming language

Wei-ern_520 wrote:

Sid72020123 wrote:

Wei-ern_520 wrote:

scott170 wrote:

what would be some ways you would use a walrus operator? also why is this forum dead now
Blah blah blah

I am working on a python program that can connect the cloud variables in Python!
Sounds kewl! (cool)
It's already done! See here: https://pypi.org/project/scratchconnect/

Hello!
scott170
Scratcher
84 posts

Python programming language

Sid72020123 wrote:

Wei-ern_520 wrote:

Sid72020123 wrote:

Wei-ern_520 wrote:

scott170 wrote:

what would be some ways you would use a walrus operator? also why is this forum dead now
Blah blah blah

I am working on a python program that can connect the cloud variables in Python!
Sounds kewl! (cool)
It's already done! See here: https://pypi.org/project/scratchconnect/
nice!
Sid72020123
Scratcher
500+ posts

Python programming language

scott170 wrote:

Sid72020123 wrote:

Wei-ern_520 wrote:

Sid72020123 wrote:

Wei-ern_520 wrote:

scott170 wrote:

what would be some ways you would use a walrus operator? also why is this forum dead now
Blah blah blah

I am working on a python program that can connect the cloud variables in Python!
Sounds kewl! (cool)
It's already done! See here: https://pypi.org/project/scratchconnect/
nice!
But very less people use that

Hello!
Wei-ern_520
Scratcher
500+ posts

Python programming language

Here's a metroidvania like engine I'm working on:

import pygame
pygame.init()
screen_size = (640, 480)
screen = pygame.display.set_mode(screen_size)
display = pygame.Surface((320, 240))
clock = pygame.time.Clock()
tilesize = 16
fps = 60
class Player():
	def __init__(self):
		self.rect = pygame.Rect(16, 160, 16, 16)
		self.x_speed = 0
		self.y_speed = 0
		self.image = pygame.Surface((16, 16))
		self.image.fill((255, 0, 0))
		self.jump = 0
		self.gravity = 0.25 #0.25
		self.jump_height = -5
		self.collide_platform = True
		
class Game():
	def __init__(self, level, tiles):
		self.layer = "walls"
		self.level = level
		self.tiles = tiles
		self.player = Player()
		self.play = True
		self.level_xy = 0
		self.m_width = 3
		self.count = 0
		self.location = ""
		
	def draw_tiles(self):
		self.collide_tiles = []
		self.platforms = []
		for y, row in enumerate(self.tiles[self.level_xy]):
			for x, column in enumerate(row):
				if not column == "0":
					if column == "p":
						current_tile = pygame.Rect(x * tilesize, y * tilesize, tilesize, tilesize)
						display.blit(all_tiles[self.layer][column], (x * tilesize, y* tilesize))
						self.platforms.append(current_tile)
					else:
						current_tile = pygame.Rect(x * tilesize, y * tilesize, tilesize, tilesize)
						display.blit(all_tiles[self.layer][column], (x * tilesize, y* tilesize))
						self.collide_tiles.append(current_tile)
						
	def handle_platforms(self, platforms):
		for platform in platforms:
			if self.player.rect.bottom < platform.centery:
				if self.player.y_speed > 0:
					if self.player.collide_platform == True:
						if self.player.rect.colliderect(platform):
							self.player.rect.bottom = platform.top
							self.player.y_speed = 0
							self.player.jump = 0
						
				
	def check_collide(self, tiles):
		t = []
		for tile in tiles:
			if self.player.rect.colliderect(tile):
				t.append (tile)
		return t
		
	def move_player(self):
		keys = pygame.key.get_pressed()
		if keys[pygame.K_RIGHT] or keys[pygame.K_d]:
			self.player.x_speed += 1
			if self.player.x_speed > 3:
				self.player.x_speed = 3
		if keys[pygame.K_LEFT] or keys[pygame.K_a]:
			self.player.x_speed += -1
			if self.player.x_speed < -3:
				self.player.x_speed = -3
		if keys[pygame.K_UP] or keys[pygame.K_w]:
			if self.player.jump < 4:
				self.player.y_speed = self.player.jump_height
				
		if keys[pygame.K_DOWN] or keys[pygame.K_s]:
			self.player.collide_platform = False
			self.count = 0
		if self.count > 8:
			self.player.collide_platform = True
			self.count = 0
			
	def update_player(self):
		self.player.x_speed *= 0.8
		self.player.rect.x += int(self.player.x_speed)
		self.hit_tiles=[]
		self.hit_tiles = self.check_collide(self.collide_tiles)
		for tiles in self.hit_tiles:
			if self.player.x_speed > 0:
				self.player.rect.right = tiles.left
				self.player.x_speed = 0
			if self.player.x_speed < 0:
				self.player.rect.left = tiles.right
				self.player.x_speed = 0
				
		if self.player.y_speed < 7.5:
			self.player.y_speed += self.player.gravity
		self.player.rect.y += self.player.y_speed
		self.player.jump += 1
		self.handle_platforms(self.platforms)
		self.hit_tiles=[]
		self.hit_tiles = self.check_collide(self.collide_tiles)
		for tiles in self.hit_tiles:
			if self.player.y_speed > 0:
				self.player.rect.bottom = tiles.top
				self.player.y_speed = 0
				self.player.jump = 0
			if self.player.y_speed < 0:
				self.player.rect.top = tiles.bottom
				self.player.y_speed = 0
								
	def next_screen(self):
		if self.player.rect.left < 0:
			self.level_xy -= 1
			self.player.rect.right = 320
		elif self.player.rect.right > 320:
			self.level_xy += 1
			self.player.rect.left = 0
		elif self.player.rect.top < 0:
			self.level_xy -= self.m_width
			self.player.rect.bottom = 240
		elif self.player.rect.bottom > 240:
			self.level_xy += self.m_width
			self.player.rect.top = 0
			
			
	def update(self):
		screen.fill((255,255,255))
		display.fill((255, 255, 255))
		self.draw_tiles()
		
		if self.player.collide_platform == False:
			self.count += 1
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				self.play = False
				
		self.move_player()
		self.update_player()
		self.next_screen()
		display.blit(self.player.image, (self.player.rect.x, self.player.rect.y))
		screen.blit(pygame.transform.scale(display, (screen_size)), (0, 0))		
		clock.tick(fps)
		pygame.display.update()
					
level = 0
plat = pygame.Surface((16,16))
plat.fill((80,40,0))
all_tiles = {
"walls": {
"0": 0, 
"1": pygame.Surface((tilesize, tilesize)),
"b": pygame.Surface((tilesize, tilesize)),
"p": plat
}
}
tiles = [
[
"11111111111111111111",
"10000000000000000000",
"10000000000000000000",
"11111111111111111001",
"10000000000000000001",
"10000000000000000001",
"11111111100111111111",
"10000000000000000001",
"10000000000000000001",
"10011111111111111111",
"10000000000000000000",
"10000000000000000000",
"10000000000111111111",
"10011000000001111111",
"11111111111001111111"
], 
[
"11111111111111111111",
"00000000000000000000",
"00000000000000000000",
"10011111111111111001",
"10000000010000000001",
"10000000010000000001",
"11111111110011111111",
"10000000000000000001",
"10000000000000000001",
"11111111110011111111",
"00000000000000000001",
"00000000000000000001",
"11111111111001111111",
"11111111111001111111",
"11111111111001111111"
],
[
"11111111111111111111",
"00000000000000000001",
"00000000000000000001",
"11111111111000000001",
"100000000000000pp001",
"10000000000000000001",
"100000000pp000000001",
"10000000000000000001",
"100pp000000000000001",
"10000000000000000001",
"100000000pp000000001",
"10000000000000000001",
"100000000000000pp001",
"10000000000000000001",
"111111111pp111111111"
],
[
"11111111111001111111",
"10000000000000000000",
"10000000000000000000",
"10011111111111111001",
"10000000000000000001",
"10000000000000000001",
"11111111111111111pp1",
"10000000000000000000",
"10000000000000000000",
"11111111001111111pp1",
"11111111000000000000",
"11111111111111111001",
"11111111111111111pp1",
"11111111111111111001",
"11111111111111111111"
],
[
"11111111111001111111",
"00000000000000000001",
"00000000000000000001",
"10011111111111111111",
"10000000000000000001",
"10000000000000000001",
"11111111111111111001",
"00000000000000000001",
"00000000000000000001",
"11111111111111111101",
"00000000000000000001",
"111111111111111111p1",
"11111111111111111100",
"11111111111111111100",
"11111111111111111111"
],
[
"11111111100111111111",
"10000000000000000001",
"100000000pp000000001",
"10000000000000000001",
"100000000000000pp001",
"10000000000000000001",
"100000000pp000000001",
"10000000000000000001",
"100pp000000000000001",
"10000000000000000001",
"100000000pp000000001",
"10000000000000000001",
"000000000000000pp001",
"00000000000000000001",
"11111111111111111111"
],
]
g = Game(level, tiles)
while g.play:
	g.update()
pygame.quit()

Last edited by Wei-ern_520 (Oct. 16, 2021 06:24:56)


Please consider checking out my suggestion ->here<-.

Hello, I’m Wei-ern_520, and I will randomly appear in your room! Just kidding, I make rpg engines.

I have no custom pfp, not because I don't know how to make one. I just don't know what suits me best, and I'm just too lazy and prefer sticking to simplicity. Or at least so. I also have the need to trip people with my profile picture. Just wait till it happens.

Fun fact: you don't clean your mess, you move it somewhere else. (Source: somewhere)

Also: Ooh, look at the cheese!
scott170
Scratcher
84 posts

Python programming language

Wei-ern_520 wrote:

Here's a metroidvania like engine I'm working on:

import pygame
pygame.init()
screen_size = (640, 480)
screen = pygame.display.set_mode(screen_size)
display = pygame.Surface((320, 240))
clock = pygame.time.Clock()
tilesize = 16
fps = 60
class Player():
	def __init__(self):
		self.rect = pygame.Rect(16, 160, 16, 16)
		self.x_speed = 0
		self.y_speed = 0
		self.image = pygame.Surface((16, 16))
		self.image.fill((255, 0, 0))
		self.jump = 0
		self.gravity = 0.25 #0.25
		self.jump_height = -5
		self.collide_platform = True
		
class Game():
	def __init__(self, level, tiles):
		self.layer = "walls"
		self.level = level
		self.tiles = tiles
		self.player = Player()
		self.play = True
		self.level_xy = 0
		self.m_width = 3
		self.count = 0
		self.location = ""
		
	def draw_tiles(self):
		self.collide_tiles = []
		self.platforms = []
		for y, row in enumerate(self.tiles[self.level_xy]):
			for x, column in enumerate(row):
				if not column == "0":
					if column == "p":
						current_tile = pygame.Rect(x * tilesize, y * tilesize, tilesize, tilesize)
						display.blit(all_tiles[self.layer][column], (x * tilesize, y* tilesize))
						self.platforms.append(current_tile)
					else:
						current_tile = pygame.Rect(x * tilesize, y * tilesize, tilesize, tilesize)
						display.blit(all_tiles[self.layer][column], (x * tilesize, y* tilesize))
						self.collide_tiles.append(current_tile)
						
	def handle_platforms(self, platforms):
		for platform in platforms:
			if self.player.rect.bottom < platform.centery:
				if self.player.y_speed > 0:
					if self.player.collide_platform == True:
						if self.player.rect.colliderect(platform):
							self.player.rect.bottom = platform.top
							self.player.y_speed = 0
							self.player.jump = 0
						
				
	def check_collide(self, tiles):
		t = []
		for tile in tiles:
			if self.player.rect.colliderect(tile):
				t.append (tile)
		return t
		
	def move_player(self):
		keys = pygame.key.get_pressed()
		if keys[pygame.K_RIGHT] or keys[pygame.K_d]:
			self.player.x_speed += 1
			if self.player.x_speed > 3:
				self.player.x_speed = 3
		if keys[pygame.K_LEFT] or keys[pygame.K_a]:
			self.player.x_speed += -1
			if self.player.x_speed < -3:
				self.player.x_speed = -3
		if keys[pygame.K_UP] or keys[pygame.K_w]:
			if self.player.jump < 4:
				self.player.y_speed = self.player.jump_height
				
		if keys[pygame.K_DOWN] or keys[pygame.K_s]:
			self.player.collide_platform = False
			self.count = 0
		if self.count > 8:
			self.player.collide_platform = True
			self.count = 0
			
	def update_player(self):
		self.player.x_speed *= 0.8
		self.player.rect.x += int(self.player.x_speed)
		self.hit_tiles=[]
		self.hit_tiles = self.check_collide(self.collide_tiles)
		for tiles in self.hit_tiles:
			if self.player.x_speed > 0:
				self.player.rect.right = tiles.left
				self.player.x_speed = 0
			if self.player.x_speed < 0:
				self.player.rect.left = tiles.right
				self.player.x_speed = 0
				
		if self.player.y_speed < 7.5:
			self.player.y_speed += self.player.gravity
		self.player.rect.y += self.player.y_speed
		self.player.jump += 1
		self.handle_platforms(self.platforms)
		self.hit_tiles=[]
		self.hit_tiles = self.check_collide(self.collide_tiles)
		for tiles in self.hit_tiles:
			if self.player.y_speed > 0:
				self.player.rect.bottom = tiles.top
				self.player.y_speed = 0
				self.player.jump = 0
			if self.player.y_speed < 0:
				self.player.rect.top = tiles.bottom
				self.player.y_speed = 0
								
	def next_screen(self):
		if self.player.rect.left < 0:
			self.level_xy -= 1
			self.player.rect.right = 320
		elif self.player.rect.right > 320:
			self.level_xy += 1
			self.player.rect.left = 0
		elif self.player.rect.top < 0:
			self.level_xy -= self.m_width
			self.player.rect.bottom = 240
		elif self.player.rect.bottom > 240:
			self.level_xy += self.m_width
			self.player.rect.top = 0
			
			
	def update(self):
		screen.fill((255,255,255))
		display.fill((255, 255, 255))
		self.draw_tiles()
		
		if self.player.collide_platform == False:
			self.count += 1
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				self.play = False
				
		self.move_player()
		self.update_player()
		self.next_screen()
		display.blit(self.player.image, (self.player.rect.x, self.player.rect.y))
		screen.blit(pygame.transform.scale(display, (screen_size)), (0, 0))		
		clock.tick(fps)
		pygame.display.update()
					
level = 0
plat = pygame.Surface((16,16))
plat.fill((80,40,0))
all_tiles = {
"walls": {
"0": 0, 
"1": pygame.Surface((tilesize, tilesize)),
"b": pygame.Surface((tilesize, tilesize)),
"p": plat
}
}
tiles = [
[
"11111111111111111111",
"10000000000000000000",
"10000000000000000000",
"11111111111111111001",
"10000000000000000001",
"10000000000000000001",
"11111111100111111111",
"10000000000000000001",
"10000000000000000001",
"10011111111111111111",
"10000000000000000000",
"10000000000000000000",
"10000000000111111111",
"10011000000001111111",
"11111111111001111111"
], 
[
"11111111111111111111",
"00000000000000000000",
"00000000000000000000",
"10011111111111111001",
"10000000010000000001",
"10000000010000000001",
"11111111110011111111",
"10000000000000000001",
"10000000000000000001",
"11111111110011111111",
"00000000000000000001",
"00000000000000000001",
"11111111111001111111",
"11111111111001111111",
"11111111111001111111"
],
[
"11111111111111111111",
"00000000000000000001",
"00000000000000000001",
"11111111111000000001",
"100000000000000pp001",
"10000000000000000001",
"100000000pp000000001",
"10000000000000000001",
"100pp000000000000001",
"10000000000000000001",
"100000000pp000000001",
"10000000000000000001",
"100000000000000pp001",
"10000000000000000001",
"111111111pp111111111"
],
[
"11111111111001111111",
"10000000000000000000",
"10000000000000000000",
"10011111111111111001",
"10000000000000000001",
"10000000000000000001",
"11111111111111111pp1",
"10000000000000000000",
"10000000000000000000",
"11111111001111111pp1",
"11111111000000000000",
"11111111111111111001",
"11111111111111111pp1",
"11111111111111111001",
"11111111111111111111"
],
[
"11111111111001111111",
"00000000000000000001",
"00000000000000000001",
"10011111111111111111",
"10000000000000000001",
"10000000000000000001",
"11111111111111111001",
"00000000000000000001",
"00000000000000000001",
"11111111111111111101",
"00000000000000000001",
"111111111111111111p1",
"11111111111111111100",
"11111111111111111100",
"11111111111111111111"
],
[
"11111111100111111111",
"10000000000000000001",
"100000000pp000000001",
"10000000000000000001",
"100000000000000pp001",
"10000000000000000001",
"100000000pp000000001",
"10000000000000000001",
"100pp000000000000001",
"10000000000000000001",
"100000000pp000000001",
"10000000000000000001",
"000000000000000pp001",
"00000000000000000001",
"11111111111111111111"
],
]
g = Game(level, tiles)
while g.play:
	g.update()
pygame.quit()
wow nice
mumu245
Scratcher
1000+ posts

Python programming language

scott170 wrote:

Wei-ern_520 wrote:

Here's a metroidvania like engine I'm working on:

import pygame
pygame.init()
screen_size = (640, 480)
screen = pygame.display.set_mode(screen_size)
display = pygame.Surface((320, 240))
clock = pygame.time.Clock()
tilesize = 16
fps = 60
class Player():
	def __init__(self):
		self.rect = pygame.Rect(16, 160, 16, 16)
		self.x_speed = 0
		self.y_speed = 0
		self.image = pygame.Surface((16, 16))
		self.image.fill((255, 0, 0))
		self.jump = 0
		self.gravity = 0.25 #0.25
		self.jump_height = -5
		self.collide_platform = True
		
class Game():
	def __init__(self, level, tiles):
		self.layer = "walls"
		self.level = level
		self.tiles = tiles
		self.player = Player()
		self.play = True
		self.level_xy = 0
		self.m_width = 3
		self.count = 0
		self.location = ""
		
	def draw_tiles(self):
		self.collide_tiles = []
		self.platforms = []
		for y, row in enumerate(self.tiles[self.level_xy]):
			for x, column in enumerate(row):
				if not column == "0":
					if column == "p":
						current_tile = pygame.Rect(x * tilesize, y * tilesize, tilesize, tilesize)
						display.blit(all_tiles[self.layer][column], (x * tilesize, y* tilesize))
						self.platforms.append(current_tile)
					else:
						current_tile = pygame.Rect(x * tilesize, y * tilesize, tilesize, tilesize)
						display.blit(all_tiles[self.layer][column], (x * tilesize, y* tilesize))
						self.collide_tiles.append(current_tile)
						
	def handle_platforms(self, platforms):
		for platform in platforms:
			if self.player.rect.bottom < platform.centery:
				if self.player.y_speed > 0:
					if self.player.collide_platform == True:
						if self.player.rect.colliderect(platform):
							self.player.rect.bottom = platform.top
							self.player.y_speed = 0
							self.player.jump = 0
						
				
	def check_collide(self, tiles):
		t = []
		for tile in tiles:
			if self.player.rect.colliderect(tile):
				t.append (tile)
		return t
		
	def move_player(self):
		keys = pygame.key.get_pressed()
		if keys[pygame.K_RIGHT] or keys[pygame.K_d]:
			self.player.x_speed += 1
			if self.player.x_speed > 3:
				self.player.x_speed = 3
		if keys[pygame.K_LEFT] or keys[pygame.K_a]:
			self.player.x_speed += -1
			if self.player.x_speed < -3:
				self.player.x_speed = -3
		if keys[pygame.K_UP] or keys[pygame.K_w]:
			if self.player.jump < 4:
				self.player.y_speed = self.player.jump_height
				
		if keys[pygame.K_DOWN] or keys[pygame.K_s]:
			self.player.collide_platform = False
			self.count = 0
		if self.count > 8:
			self.player.collide_platform = True
			self.count = 0
			
	def update_player(self):
		self.player.x_speed *= 0.8
		self.player.rect.x += int(self.player.x_speed)
		self.hit_tiles=[]
		self.hit_tiles = self.check_collide(self.collide_tiles)
		for tiles in self.hit_tiles:
			if self.player.x_speed > 0:
				self.player.rect.right = tiles.left
				self.player.x_speed = 0
			if self.player.x_speed < 0:
				self.player.rect.left = tiles.right
				self.player.x_speed = 0
				
		if self.player.y_speed < 7.5:
			self.player.y_speed += self.player.gravity
		self.player.rect.y += self.player.y_speed
		self.player.jump += 1
		self.handle_platforms(self.platforms)
		self.hit_tiles=[]
		self.hit_tiles = self.check_collide(self.collide_tiles)
		for tiles in self.hit_tiles:
			if self.player.y_speed > 0:
				self.player.rect.bottom = tiles.top
				self.player.y_speed = 0
				self.player.jump = 0
			if self.player.y_speed < 0:
				self.player.rect.top = tiles.bottom
				self.player.y_speed = 0
								
	def next_screen(self):
		if self.player.rect.left < 0:
			self.level_xy -= 1
			self.player.rect.right = 320
		elif self.player.rect.right > 320:
			self.level_xy += 1
			self.player.rect.left = 0
		elif self.player.rect.top < 0:
			self.level_xy -= self.m_width
			self.player.rect.bottom = 240
		elif self.player.rect.bottom > 240:
			self.level_xy += self.m_width
			self.player.rect.top = 0
			
			
	def update(self):
		screen.fill((255,255,255))
		display.fill((255, 255, 255))
		self.draw_tiles()
		
		if self.player.collide_platform == False:
			self.count += 1
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				self.play = False
				
		self.move_player()
		self.update_player()
		self.next_screen()
		display.blit(self.player.image, (self.player.rect.x, self.player.rect.y))
		screen.blit(pygame.transform.scale(display, (screen_size)), (0, 0))		
		clock.tick(fps)
		pygame.display.update()
					
level = 0
plat = pygame.Surface((16,16))
plat.fill((80,40,0))
all_tiles = {
"walls": {
"0": 0, 
"1": pygame.Surface((tilesize, tilesize)),
"b": pygame.Surface((tilesize, tilesize)),
"p": plat
}
}
tiles = [
[
"11111111111111111111",
"10000000000000000000",
"10000000000000000000",
"11111111111111111001",
"10000000000000000001",
"10000000000000000001",
"11111111100111111111",
"10000000000000000001",
"10000000000000000001",
"10011111111111111111",
"10000000000000000000",
"10000000000000000000",
"10000000000111111111",
"10011000000001111111",
"11111111111001111111"
], 
[
"11111111111111111111",
"00000000000000000000",
"00000000000000000000",
"10011111111111111001",
"10000000010000000001",
"10000000010000000001",
"11111111110011111111",
"10000000000000000001",
"10000000000000000001",
"11111111110011111111",
"00000000000000000001",
"00000000000000000001",
"11111111111001111111",
"11111111111001111111",
"11111111111001111111"
],
[
"11111111111111111111",
"00000000000000000001",
"00000000000000000001",
"11111111111000000001",
"100000000000000pp001",
"10000000000000000001",
"100000000pp000000001",
"10000000000000000001",
"100pp000000000000001",
"10000000000000000001",
"100000000pp000000001",
"10000000000000000001",
"100000000000000pp001",
"10000000000000000001",
"111111111pp111111111"
],
[
"11111111111001111111",
"10000000000000000000",
"10000000000000000000",
"10011111111111111001",
"10000000000000000001",
"10000000000000000001",
"11111111111111111pp1",
"10000000000000000000",
"10000000000000000000",
"11111111001111111pp1",
"11111111000000000000",
"11111111111111111001",
"11111111111111111pp1",
"11111111111111111001",
"11111111111111111111"
],
[
"11111111111001111111",
"00000000000000000001",
"00000000000000000001",
"10011111111111111111",
"10000000000000000001",
"10000000000000000001",
"11111111111111111001",
"00000000000000000001",
"00000000000000000001",
"11111111111111111101",
"00000000000000000001",
"111111111111111111p1",
"11111111111111111100",
"11111111111111111100",
"11111111111111111111"
],
[
"11111111100111111111",
"10000000000000000001",
"100000000pp000000001",
"10000000000000000001",
"100000000000000pp001",
"10000000000000000001",
"100000000pp000000001",
"10000000000000000001",
"100pp000000000000001",
"10000000000000000001",
"100000000pp000000001",
"10000000000000000001",
"000000000000000pp001",
"00000000000000000001",
"11111111111111111111"
],
]
g = Game(level, tiles)
while g.play:
	g.update()
pygame.quit()
wow nice
Cool!

select this text then press Ctrl+Shift+Down to read more
Wei-ern_520
Scratcher
500+ posts

Python programming language

scott170 wrote:

Wei-ern_520 wrote:

Here's a metroidvania like engine I'm working on:
wow nice

mumu245 wrote:

Wei-ern_520 wrote:

Here's a metroidvania like engine I'm working on:
Cool!

Thanks. I'm trying to implement more features into this thing.

Please consider checking out my suggestion ->here<-.

Hello, I’m Wei-ern_520, and I will randomly appear in your room! Just kidding, I make rpg engines.

I have no custom pfp, not because I don't know how to make one. I just don't know what suits me best, and I'm just too lazy and prefer sticking to simplicity. Or at least so. I also have the need to trip people with my profile picture. Just wait till it happens.

Fun fact: you don't clean your mess, you move it somewhere else. (Source: somewhere)

Also: Ooh, look at the cheese!
-EmeraldThunder-
Scratcher
1000+ posts

Python programming language

Bump and also, I've been trying to create a chess game and I can't draw the board.
Can someone help me debug this code:
import pygame
from pygame.locals import *
from globals import *
from piece import Piece
class Board:
    def __init__(self, width, height, tileWidth, tileHeight, x, y):
        self.width = width
        self.height = height
        self.tileWidth = tileWidth
        self.tileHeight = tileHeight
        self.board = pygame.Surface((tileWidth*width, tileHeight*height))
        self.x = x
        self.y = y
    def draw(self, scrn):
        for y in range(0, self.height):
            for x in range(0, self.width):
                pygame.draw.rect(self.board, BLACK if (x*y)%2 == 0 else WHITE, pygame.Rect(x * self.tileWidth, y * self.tileHeight, self.tileWidth, self.tileHeight))
        scrn.blit(self.board, (self.x, self.y))
    def update(self, e):
        pass


Nothing here.
Wei-ern_520
Scratcher
500+ posts

Python programming language

-EmeraldThunder- wrote:

Bump and also, I've been trying to create a chess game and I can't draw the board.
Can someone help me debug this code:
import pygame
from pygame.locals import *
from globals import *
from piece import Piece
class Board:
    def __init__(self, width, height, tileWidth, tileHeight, x, y):
        self.width = width
        self.height = height
        self.tileWidth = tileWidth
        self.tileHeight = tileHeight
        self.board = pygame.Surface((tileWidth*width, tileHeight*height))
        self.x = x
        self.y = y
    def draw(self, scrn):
         a=0
        for y in range(0, self.height):
            for x in range(0, self.width):
               a += 1
                pygame.draw.rect(self.board, WHITE if a%2 == 0 else BLACK, pygame.Rect(x * self.tileWidth, y * self.tileHeight, self.tileWidth, self.tileHeight))
        scrn.blit(self.board, (self.x, self.y))
    def update(self, e):
        pass

Try: above. I fixed it I think

Edit: Please don't just ctrl+c and v this, there are some indentation errors.

Last edited by Wei-ern_520 (Oct. 25, 2021 12:53:00)


Please consider checking out my suggestion ->here<-.

Hello, I’m Wei-ern_520, and I will randomly appear in your room! Just kidding, I make rpg engines.

I have no custom pfp, not because I don't know how to make one. I just don't know what suits me best, and I'm just too lazy and prefer sticking to simplicity. Or at least so. I also have the need to trip people with my profile picture. Just wait till it happens.

Fun fact: you don't clean your mess, you move it somewhere else. (Source: somewhere)

Also: Ooh, look at the cheese!
-EmeraldThunder-
Scratcher
1000+ posts

Python programming language

Wei-ern_520 wrote:

-EmeraldThunder- wrote:

Bump and also, I've been trying to create a chess game and I can't draw the board.
Can someone help me debug this code:
import pygame
from pygame.locals import *
from globals import *
from piece import Piece
class Board:
    def __init__(self, width, height, tileWidth, tileHeight, x, y):
        self.width = width
        self.height = height
        self.tileWidth = tileWidth
        self.tileHeight = tileHeight
        self.board = pygame.Surface((tileWidth*width, tileHeight*height))
        self.x = x
        self.y = y
    def draw(self, scrn):
         a=0
        for y in range(0, self.height):
            for x in range(0, self.width):
               a += 1
                pygame.draw.rect(self.board, WHITE if a%2 == 0 else BLACK, pygame.Rect(x * self.tileWidth, y * self.tileHeight, self.tileWidth, self.tileHeight))
        scrn.blit(self.board, (self.x, self.y))
    def update(self, e):
        pass

Try: above. I fixed it I think

Edit: Please don't just ctrl+c and v this, there are some indentation errors.

Nothing here.
ScratchCatHELLO
Scratcher
1000+ posts

Python programming language

-EmeraldThunder- wrote:

Bump and also, I've been trying to create a chess game and I can't draw the board.
Can someone help me debug this code:
import pygame
from pygame.locals import *
from globals import *
from piece import Piece
class Board:
    def __init__(self, width, height, tileWidth, tileHeight, x, y):
        self.width = width
        self.height = height
        self.tileWidth = tileWidth
        self.tileHeight = tileHeight
        self.board = pygame.Surface((tileWidth*width, tileHeight*height))
        self.x = x
        self.y = y
    def draw(self, scrn):
        for y in range(0, self.height):
            for x in range(0, self.width):
                pygame.draw.rect(self.board, BLACK if (x*y)%2 == 0 else WHITE, pygame.Rect(x * self.tileWidth, y * self.tileHeight, self.tileWidth, self.tileHeight))
        scrn.blit(self.board, (self.x, self.y))
    def update(self, e):
        pass

use x%2^y%2 for the condition (you might need to use “not x%2^y%2“, I didn’t check whether it matched a chess board)

Last edited by ScratchCatHELLO (Oct. 26, 2021 01:21:36)






ScratchCatHELLO
I have 5600+ posts, I've been on scratch for 5 1/2 years, I'm a Forum Helper™ and I have a Scratch Wiki account!
I like: Python, CSS, Javascript, Rust



Python 3 Text Adventure
cool new browser game - cursed laughing-crying emoji - Illuminati - you know waterbenders, but do you know stock-imagebenders? - snek - vibin' - Bump song (vevo) - Speed bump - yee - fred - m i c k e y
Wei-ern_520
Scratcher
500+ posts

Python programming language

-EmeraldThunder- wrote:

import pygame
from pygame.locals import *
from globals import *
from piece import Piece
class Board:
    def __init__(self, width, height, tileWidth, tileHeight, x, y):
        self.width = width
        self.height = height
        self.tileWidth = tileWidth
        self.tileHeight = tileHeight
        self.board = pygame.Surface((tileWidth*width, tileHeight*height))
        self.x = x
        self.y = y
    def draw(self, scrn):
        a=0
        for y in range(0, self.height):
            for x in range(0, self.width):
                a += 1
                pygame.draw.rect(self.board, WHITE if a%2 == 0 else BLACK, pygame.Rect(x * self.tileWidth, y * self.tileHeight, self.tileWidth, self.tileHeight))
        scrn.blit(self.board, (self.x, self.y))
    def update(self, e):
        pass


It should work. Are you sure you got the indentations right? It worked for me. Also, you might wanna consider giving the code for those modules for extra precision.

Last edited by Wei-ern_520 (Oct. 26, 2021 09:06:35)


Please consider checking out my suggestion ->here<-.

Hello, I’m Wei-ern_520, and I will randomly appear in your room! Just kidding, I make rpg engines.

I have no custom pfp, not because I don't know how to make one. I just don't know what suits me best, and I'm just too lazy and prefer sticking to simplicity. Or at least so. I also have the need to trip people with my profile picture. Just wait till it happens.

Fun fact: you don't clean your mess, you move it somewhere else. (Source: somewhere)

Also: Ooh, look at the cheese!

Powered by DjangoBB