···11+#indented properly now
22+from ursina import *
33+from itertools import product
44+55+66+def parent_child(axel, layer):
77+ # Iterate over existing cubes to round their world position/rotation
88+ for c in cube:
99+ c.position, c.rotation = round(c.world_position, 1), c.world_rotation
1010+1111+ # Detach all cubes from their current parents (default is scene or previous hierarchy)
1212+ c.parent = scene
1313+ center.rotation = 0
1414+1515+ # Re-parent specific layers to the 'center' entity
1616+ for c in cube:
1717+ if eval(f"c.position.{axel}") == layer:
1818+ c.parent = center
1919+2020+2121+def input(key):
2222+ if key not in rot_dict:
2323+ return
2424+2525+ axle, layer, angle = rot_dict[key]
2626+ parent_child(axle, layer)
2727+2828+ shift = held_keys['shift']
2929+3030+ # Construct the animation command dynamically
3131+ anim_cmd = f"center.animate_rotation_{axle}"
3232+ eval(f"{anim_cmd}({-angle if shift else angle}, duration=0.5)")
3333+3434+3535+app = Ursina()
3636+3737+window.borderless = False
3838+window.size = (800, 800)
3939+window.position = (2000, 200)
4040+EditorCamera()
4141+4242+center = Entity()
4343+4444+rot_dict = {
4545+ 'u': ['y', 1, 90], # Up
4646+ 'e': ['y', 0, -90], # Even (middle layer Y?)
4747+ 'd': ['y', -1, -90], # Down
4848+4949+ 'l': ['x', -1, -90], # Left
5050+ 'm': ['x', 0, -90], # Middle layer X?
5151+ 'r': ['x', 1, 90], # Right
5252+5353+ 'f': ['z', -1, 90], # Front
5454+ 's': ['z', 0, 90], # Back/Side?
5555+ 'b': ['z', 1, -90] # Back
5656+}
5757+5858+cube = []
5959+for pos in product((-1, 0, 1), repeat=3):
6060+ cube.append(
6161+ Entity(
6262+ model='rubiks_model.obj',
6363+ texture='rubikscube.png',
6464+ position=pos,
6565+ scale=0.5
6666+ )
6767+ )
6868+ # print(pos) # Debugging print (commented out as per your original code)
6969+ # checked that it worked
7070+7171+app.run()
7272+
+53
rubiks_OOJ.py
···11+22+'''
33+44+makin a rubix cube simulation
55+the OOJ way!!
66+77+'''
88+### trying it the ObJeCtEd ORiEnTed method way
99+# because that is coOL
1010+from ursina import *
1111+import ursina as urs
1212+from ursina.prefabs import Button
1313+1414+x = Button()
1515+1616+#create a window
1717+app = urs.Ursina()
1818+1919+2020+# ok so now you have a window you must make en Entity
2121+# Entities area thing you place in the world
2222+# the first parameter is the model of the Entity
2323+# called 'cube'
2424+# the next parameters are the model's color
2525+#
2626+2727+player = urs.Entity(model='cube', color=urs.color.orange, scale_y=2)
2828+2929+3030+3131+# creating a function called update
3232+3333+def update():
3434+ player.x += urs.held_keys['d'] * urs.time.daylight
3535+ player.x -= urs.held_keys['a'] * urs.time.daylight
3636+ return
3737+3838+3939+# this makes the player aka the cube move left or right!
4040+# # based on input
4141+# # 0 means not pressed and 1 means pressed
4242+# # player will move the same speed regardless of how gast the game runs
4343+def my_input(key):
4444+ if key == 'space':
4545+ player.y += 1
4646+ urs.invoke(setattr, player, 'y', player.y, delay =0.2)
4747+4848+ # start running the game !
4949+ app.run()
5050+#
5151+#
5252+#
5353+#
+62
rubikszed.py
···11+# 1. Explicit Imports (Replaced 'from ursina import *')
22+from ursina import *
33+from itertools import product
44+55+66+def parent_child(axel, layer):
77+ #Iterate over existing cubes to round their world position/rotation
88+ for c in cube:
99+ c.position, c.rotation = round(c.world_position, 1), c.world_rotation
1010+1111+ # Detach all cubes from their current parents (default is scene or previous hierarchy)
1212+ c.parent = scene
1313+ center.rotation = 0
1414+1515+ # Re-parent specific layers to the 'center' entity
1616+ for c in cube:
1717+ if eval(f"c.position.{axel}") == layer:
1818+ c.parent = center
1919+2020+2121+def input(key):
2222+ if key not in rot_dict:
2323+ return
2424+2525+ axle, layer, angle = rot_dict[key]
2626+ parent_child(axle, layer)
2727+2828+ shift = held_keys["shift"]
2929+3030+ # Construct the animation command dynamically
3131+ anim_cmd = f"center.animate_rotation_{axle}"
3232+ eval(f"{anim_cmd}({-angle if shift else angle}, duration=0.5)")
3333+3434+3535+# Initialize App
3636+app = Ursina()
3737+window.borderless = False
3838+window.size = (800, 800)
3939+window.position = (2000, 200)
4040+EditorCamera()
4141+4242+center = Entity()
4343+4444+4545+rot_dict = {'u': ['y', 1, 90], 'e': ['y', 0, -90], 'd': ['y', -1, -90],
4646+4747+'l': ['x', -1, -90], 'm': ['x', 0, -90], 'r': ['x', 1, 90],
4848+4949+'f': ['z', -1, 90], 's': ['z', 0, 90], 'b': ['z', 1, -90]}
5050+5151+5252+5353+cube = []
5454+for pos in product((-1, 0, 1), repeat=3):
5555+ cube.append(
5656+ Entity(
5757+ model="models_compressed/rubiks_model.bam", texture="rubikscube.png", position=pos, scale=0.5
5858+ )
5959+ )
6060+6161+app.run()
6262+