Suoritettu

Python helper function for simple game

In a small game that I am developing, the screen is square of a given size, s, measured in pixels. The x- and y-coordinates go from (0,0) to (s-1, s-1). Boulders are rolling across the screen, and the player must avoid being hit by them. When a boulder rolls off one edge of the screen, it appears at the opposite edge of the screen, preserving the other coordinate.

For example, if s = 100 and a boulder on the middle of the right edge of the screen, at coordinate (99, 50), moves to the right, it would reappear at coordinates (0, 50) (i.e. in the middle on the left edge of the screen). The screen is essentially the surface of a torus (doughnut shape) where you can imagine the right side has been joined to the left side, and the top of the screen to the bottom.

he rolling boulders are simulated by updating their (x, y) coordinates in discrete steps. Each rolling boulder is considered to move along a trajectory defined by a sequence of discrete points:

THE i ARE subscripts.

(x0, y0), (x1, y1) ... (xi, yi)

It moves along a straight line joining consecutive points in the sequence. The trajectory of a rolling boulder is parameterised by two integers a and b so that x(i+1), y(i+1) is

x(i+1) = a(xi) - yi

y(i+1) = xi + b(yi)

If either coordinate returned by the calculation is either negative or larger than , then it is considered to wrap around to the other side of the screen, and carry on counting. For example, if s= 100 , then the coordinate (131, 257) would correspond to the point at (31,57).

Also coordinate (-1, -3) would correspond to the coordinate (99, 97).

Another example:

For function

def findPositions(a, b, s, queries):

First line (a, b, s)

Second Line (number of queries)

Lines After (queries)

If I read in the following:

2 3 100

3

1 0 3

0 1 4

1 1 3

I should get as positions

1 18

45 39

83 37

Explanation:

The first query asks if a boulder starts from (1,0) where will it end up after 3 steps. Following the rules:

(1,0) --> (2 X 1 - 0, 1 + 3 X 0) = (2,1)

--> (2 X 2 -1, 2 + 3 X 1) = (3,5)

--> (2 X 3 -5, 3 + 3 X 5) = (1, 18)

So we output 1 18 on the first line

Similarly, for the second query, find where a boulder that starts from (0,1) would be after 4 steps. The following trajectory:

(0,1) --> (2(0) - 1,0 + 3(1)) = (-1,3) = (99,3)

--> (198 -3,99+9) = (195,108) = (95,8)

--> (2(95) - 8, 95+3(8)) = (182, 119) = (82,19)

--> (164 -19, 82 + 57) = (145,139) = (45,39)

The negative coordinate to a valid screen coordinate according to the given screen width of 100 (value of s).

The third query:

(1,1) --> (2 -1, 1+3) = (1,4)

--> (2 -4, 1+ 12) = (-2,13) = (98, 13)

--> (196 - 13, 98 + 39) = (183, 137) = (83, 37)

Taidot: Python, Algorithm Analysis, Algoritmi

Näytä lisää: simple game python tkinter, simple game python, python simple game code, python opengl simple game, how to make a simple game in java, how to create a simple game in android, python import function from file in different directory, simple game in c, how to program a simple game in c, how to make a simple game in turbo c++, python helper function, simple game in android studio, simple game in prolog, simple pong game in python], simple game in netbeans, how to make a simple game in unity, simple game in flash, python apply function to list in parallel, python helper function example

Tietoa työnantajasta:
( 1 arvostelu ) Kingston, Jamaica

Projektin tunnus: #24047602

Myönnetty käyttäjälle:

panda1980mountai

Hello. I have just seen your task carefully, and can understand it. If you want, I'll finish it in an hour. Please send a message to start now. Thank you.

$30 USD 1 päivässä
(1 arvostelu)
0.8

3 freelanceria on tarjonnut keskimäärin 23$ tähän työhön

umairali8062

I have read your project and I am an expert in this field. I can do this for you within due time and honestly. I also have a few questions to discuss. Kindly contact me and we will discuss time and budget. Thanks

$20 USD 7 päivässä
(14 arvostelua)
3.8
HoangSang0532

Hi, How are you today? Thank you for your posting this project. I'm very happy to bid your project. I've read carefully your project description. I have rich experiences related with your project. Your satisfaction wi Lisää

$20 USD 1 päivässä
(0 arvostelua)
0.0