Updated the entry.
I was intending to write something quick and simple to enter but I just ran into too many issues.
No enums? Fine, I can live with having to resort to using bare integers.
Canāt use floats? Ok, I know how to write fixed point types.
Operator overloading not working for *
and /
ā¦
Having to write Vector.multiply
everywhere is just too tedious.
I know you guys worked hard on the environment and the editor,
but thereās just one too many limitations for me.
Camon @Pharap, just a little entry. To share some fun. The more we are the best will be. Bat computer will take in consideration your exit from comfort zone ;l
I think thatās as fair a judgement as any other. We understand (or at least I do)
Iām probably not going to have time in the next 2 days.
I canāt write Python as fast as languages Iām used to because I have to keep stopping to check the docs.
Also Iād have to think of a new game to write.
I was orignally going to write Asteroids,
but without floats or fixed points with operators thatās going to be pretty difficult (or at least tedious) to do.
My only other idea is Noughts & Crosses, but thatās far too simple for a decent contest entry,
and it would probably be pretty boring to write anyway.
For the record Iām comfortable writing Python code.
Itās the number of extra obstacles that cropped up that wore away at me.
Maybe you could change the name of the class to āvā and the member function to āmā so that you only have to type āv.mā. That will save you some time! Seriously though, I understand it but I would have liked to see your entry! I guess we all will have to wait until the next assembly competition!
@Pharap, yes, if you do it in a meticulous way (and you do everything in a meticulous way, which is admirable)
I had to deal with āvector mathsā also with Pyrates! How else do you think wind direction and ship direction can be taken into account?
Solution was just a simple ship unit vector vs. wind unit vector matrix table. Could easily be implemented for Asteroids-type game.Then just use vx an vy components from there on.
You know thereās autocomplete with Ctrl+space? No need to keep names short.
Single-letter identifiers are evil and should be avoided. (With a few small exceptions.)
The issue isnāt the time taken to type it (I have no problem with long identifiers),
itās the reduced readability of the resulting expressions.
With operators you can write something like:
resultVector = (position + ((direction * speed) / mass))
Without them it becomes:
resultVector = Vector.add(position, Vector.divide(Vector.multiply(direction, speed), mass))
Which is much less natural.
Admitedly itās only the multiplication and division operators that are missing,
but thatās still one operator and two functions for the example snippet.
This is as far as I got:
#
# Copyright (C) 2019 Pharap (@Pharap)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import upygame as game
import umachine as pokitto
import urandom as random
class Q8x8:
def __init__(self, value = 0):
self.value = value
def get_integer(self):
return (self.value >> 8)
def get_fractional(self):
return (self.value & 0xFF)
def __add__(self, other):
return UQ8x8(self.value + other.value)
def __sub__(self, other):
return UQ8x8(self.value - other.value)
def __mul__(self, other):
return UQ8x8((self.value * other.value) >> 8)
def __div__(self, other):
return UQ8x8((self.value << 8) / other.value)
def __floordiv__(self, other):
return UQ8x8((self.value << 8) // other.value)
def test_Q8x8():
# 1.5
a = Q8x8(0x0180)
# 2.5
b = Q8x8(0x0280)
print(a == b)
print(a != b)
print(a < b)
print(a > b)
print(a.get_integer(), a.get_fractional())
print(b.get_integer(), b.get_fractional())
c = a + b
print(c.get_integer(), c.get_fractional())
d = a - b
print(d.get_integer(), d.get_fractional())
e = a * b
print(e.get_integer(), e.get_fractional())
class Vector:
def __init__(self, x = 0, y = 0):
self.x = x
self.y = y
def __add__(self, other):
x = (self.x + other.x)
y = (self.y + other.y)
return Vector(x, y)
def __sub__(self, other):
x = (self.x - other.x)
y = (self.y - other.y)
return Vector(x, y)
def __mul__(self, scale):
x = (self.x * scale)
y = (self.y * scale)
return Vector(x, y)
def __div__(self, scale):
x = (self.x / scale)
y = (self.y / scale)
return Vector(x, y)
def __floordiv__(self, scale):
x = (self.x // scale)
y = (self.y // scale)
return Vector(x, y)
def magnitude(self):
return sqrt((self.x * self.x) + (self.y * self.y))
@staticmethod
def dot(left, right):
x = (left.x * right.x)
y = (left.y * right.y)
return (x + y)
@staticmethod
def from_angle(angle):
x = cos(angle)
y = sin(angle)
return Vector(x, y)
def test_Vector():
v = Vector(5, 5)
v -= Vector(1, 1)
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def __add__(self, vector):
x = (self.x + vector.x)
y = (self.y + vector.y)
return Point(x, y)
def __sub__(self, other):
x = (self.x - vector.x)
y = (self.y - vector.y)
return Point(x, y)
class Asteroid:
def __init__(self, position, velocity):
self.position = position
self.velocity = velocity
class Direction:
north = 0
north_east = 1
east = 2
south_east = 3
south = 4
south_west = 5
west = 6
north_west = 7
direction_vectors = [
# North
Vector(Q8x8(0x0000), Q8x8(0x0100)),
# North East
Vector(Q8x8(0x00B5), Q8x8(0x00B5)),
# East
Vector(Q8x8(0x0100), Q8x8(0x0000)),
# South East
Vector(Q8x8(0x00B5), Q8x8(0xFF4B)),
# South
Vector(Q8x8(0x0000), Q8x8(0xFF00)),
# South West
Vector(Q8x8(0xFF4B), Q8x8(0xFF4B)),
# West
Vector(Q8x8(0xFF00), Q8x8(0x0000)),
# North West
Vector(Q8x8(0xFF4B), Q8x8(0x00B5))
]
def get_direction_vector(direction):
return direction_vectors[direction]
class Ship:
def __init__(self, position, heading, velocity):
self.position = position
self.heading = heading
self.velocity = velocity
def handle_down():
return
def handle_left():
return
def handle_right():
return
def handle_up():
return
def update():
event = game.event.poll()
if event != game.NOEVENT:
print("Event")
if event.type == game.KEYDOWN:
print("Keydown")
elif event.type == game.KEYUP:
print("Keyup")
def draw():
return
def main():
while true:
update()
draw()
game.display.flip()
main()
It was never going to be anything particularly impressive.
(And thereās no point in writing a C++ version because thereās already an Asteroids game for Pokitto.)
I canāt not do it in a āmeticulousā way.
If I write it in a messy way I wonāt be able to read it if I ever look at it again.
Iāve got quite a lot of old projects like that - they do some cool stuff but I canāt make sense of half the code.
With my newer, better organised approach I can still make sense of the code even after having forgotten how it works and/or having not touched it in over a year.
People who donāt know about vectors or donāt use vectors tend to handle the x and y components separately,
which works, but doubles the (source) code size and is a pain to work with.
I finally managed to complete my entry.
ScummPy Quest I: The Jammed Door, not really a full adventure but a point-and-click puzzle.
Source: scummpy.zip (76.3 KB)
Binary: scummpy.bin (178.3 KB)
Holy shā¦
wowzaaa!
Edit: Batcomputer and @Hanski are going to have to really deliberate over all these high quality entries.
Just in time Looks very nice and is a fresh genre in this competition.
@Hanski , it is evident the decision is not going to be easy and that the great efforts that people have gone through to make the entries deserve respect.
What do you say, should we do a live stream / recorded video conference where we load and test every competition entry? I can run a wire to the Batcomputer, it has a Bathernet connection.
I agree, that they certainly have deserved it. Really great entries all
I just have not done anything like that before (public video in foreign language ), so I cannot promise 100%, but I am willing to try. Letās see how it goes.
For sure, every entry is having comments one way or another!
Edit: I prefer recorded video, so we have a chance to edit it before publishing.
Oh my goodness it is like a code/app review now Iām nervous and excited!
Of course its a review. In fact, we will look at thinks like tidiness and commenting of source, as well as suitable variable names. It will be brutal.
I deserve the most brutal sadly I already forgot what my code mostly looks like. Iām sure the variable names will be cringe worthy.
This is the largest python project Iāve ever done though.
i will finish my game tomorrow just before the dead line
i hope you will enjoy it
spoiler
Ooooh, you have to STOP this.
First ScummPy and now Commander PyKeen.
NOTE, āby 30thā means you can send your entry ON 30th. Sorry for saying it unclearly.
It is NOT so serious. On sunday the 31st I intend to start feeding the entries into the Batcomputer. I need time to conver the Python into punchcards.