Skip to content

Commit 6bbdcc3

Browse files
k3rnel-pan1c-arudravashishthaMagneticNeedle
authored
feat(app): added the option to draw arcs between two given countries (#27)
* docs(app): Added my name to team members * feat(app): added a script to get svgs for all countries * feat(app): added a script to get svgs for all countries * fix(app): Removed unnamed folder and it's files * chore(poetry): updated project authors * docs(app): move contrib section to separate file * feat(GameManager): add manager skeleton structure * feat(GameManager): complete basic event loop * chore(pygame): use `pygame-ce` * feat(UI): add skeletal main menu * feat(UI): add handlers for main menu state * feat(UI): assign object_id to buttons * feat(World Map): add fully intractable world map (#21) * feat(UI): add screen system * feat(UI): add `main_menu` and `options_menu` screen * feat(game): add basic calls to draw world map on new game * style(WORLD MAP): fill countries with fg (`00394f`) * feat(World Map): add hover state check for countries * feat(world map): scale map only when required * feat(countries): add function to get random point on sprite(not working properly) * chore(poetry): mark extras dependencies group as optional * feat(app) added the option to draw arcs between two given countries --------- Co-authored-by: Rudra Vashishtha <[email protected]> Co-authored-by: p0lygun <[email protected]>
1 parent d64f09c commit 6bbdcc3

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

game/screens/game/utils.py

+24
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
11
import math
22

3+
import pygame as pg
4+
from countries import Country
5+
36

47
def pos2angle(A, B, aspectRatio):
58
"""Calculate the angle between two points."""
69
x = B[0] - A[0]
710
y = B[1] - A[1]
811
angle = math.atan2(-y, x / aspectRatio)
912
return angle
13+
14+
15+
def draw_arcs(countries: tuple[Country, Country], curve_height: int, num_segments: int, color: tuple[int, int, int],
16+
screen: pg.Surface):
17+
"""Draw arcs between two countries."""
18+
countries_points: list[list[int, int], list[int, int]] = []
19+
for country in countries:
20+
countries_points.append(country.get_random_point())
21+
22+
x1, y1 = countries_points[0]
23+
x2, y2 = countries_points[1]
24+
25+
dx = (x2 - x1) / num_segments
26+
dy = (y2 - y1) / num_segments
27+
28+
for i in range(num_segments + 1):
29+
t = i / num_segments
30+
x = x1 + dx * i
31+
y = y1 + dy * i - curve_height * math.sin(t * math.pi)
32+
33+
pg.draw.circle(screen, color, (int(x), int(y)), 2)

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ authors = [
66
"p0lygun <[email protected]>",
77
"Hamza-Farrukh <[email protected]>",
88
"Anas-bot <[email protected]>",
9-
"Kaezrr",
10-
"rudravashishtha"
9+
"rudravashishtha <[email protected]>",
10+
"Kaezrr"
1111
]
1212
license = "MIT"
1313
readme = "README.md"

0 commit comments

Comments
 (0)