Find Jobs
Hire Freelancers

Python helper function for simple game

$10-30 USD

In Progress
Posted about 4 years ago

$10-30 USD

Paid on delivery
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)
Project ID: 24047602

About the project

1 proposal
Remote project
Active 4 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
1 freelancer is bidding on average $20 USD for this job
User Avatar
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 in 7 days
4.9 (16 reviews)
4.0
4.0

About the client

Flag of JAMAICA
Kingston, Jamaica
5.0
4
Payment method verified
Member since Jul 23, 2017

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.