Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: scale cars #1661

Merged
merged 7 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
244 changes: 120 additions & 124 deletions Pipfile.lock

Large diffs are not rendered by default.

120 changes: 68 additions & 52 deletions aimmo-game/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions aimmo-game/simulation/map_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ def get_map(self):
always_empty_location = Location(always_empty_edge_x, always_empty_edge_y)

for cell in shuffled(world_map.all_cells()):
if cell.location != always_empty_location and random.random() < self.settings.get(
"OBSTACLE_RATIO", 0.1
if (
cell.location != always_empty_location
and random.random() < self.settings.get("OBSTACLE_RATIO", 0.1)
):
cell.obstacle = Obstacle.make_obstacle()
# So long as all habitable neighbours can still reach each other, then the
Expand Down
20 changes: 9 additions & 11 deletions aimmo/worksheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,13 @@ def next_turn(world_state, avatar_state):
#
# New commands:
# - DropAction(index)
# - backpack.find(ARTEFACT)
# - backpack.find(ARTEFACT_TYPE)
#
# Previous commands:
# - world_state.scan_nearby() -> LIST OF ARTEFACTS
# - MoveTowardsAction(ARTEFACT)
# - avatar_state.backpack -> LIST OF HELD ARTEFACTS
# - artefact.type -> TYPE (e.g. artefact_types.KEY or artefact_types.CHEST)
#-------------------------------------------------------------------------------

def next_turn(world_state, avatar_state):
Expand Down Expand Up @@ -261,19 +267,11 @@ def next_turn(world_state, avatar_state):


def get_complete_worksheets() -> List[Worksheet]:
return [
worksheet
for worksheet in WORKSHEETS.values()
if worksheet.thumbnail_text != "Coming Soon"
]
return [worksheet for worksheet in WORKSHEETS.values() if worksheet.thumbnail_text != "Coming Soon"]


def get_incomplete_worksheets() -> List[Worksheet]:
return [
worksheet
for worksheet in WORKSHEETS.values()
if worksheet.thumbnail_text == "Coming Soon"
]
return [worksheet for worksheet in WORKSHEETS.values() if worksheet.thumbnail_text == "Coming Soon"]


def get_worksheets_excluding_id(id: int) -> List[Worksheet]:
Expand Down
12 changes: 6 additions & 6 deletions game_frontend/src/babylon/assetPacks/ancient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
TransformNode,
AbstractMesh,
Scene,
Color4
Color4,
} from 'babylonjs'
import AssetPack from './assetPack'

Expand All @@ -15,12 +15,12 @@ export default class AncientAssetPack extends AssetPack {

backgroundColor = new Color4(0.93, 0.89, 0.82)

constructor (era: string, scene: Scene) {
constructor(era: string, scene: Scene) {
super(era, scene)
this.obstacleMaterial = this.makeObstacleMaterial()
}

async createInteractable (
async createInteractable(
name: string,
type: string,
location: Vector3,
Expand All @@ -39,20 +39,20 @@ export default class AncientAssetPack extends AssetPack {
interactable.position = location
interactable.scaling = new Vector3(0.4, 0.4, 0.4)
interactable.metadata = {
type: type
type: type,
}
return interactable
}

makeObstacleMaterial (): StandardMaterial {
makeObstacleMaterial(): StandardMaterial {
const material = new StandardMaterial(this.obstacleInfo.materialName, this.scene)
material.diffuseTexture = new Texture(this.getTextureURL(1), this.scene)
material.specularColor = new Color3(0, 0, 0)
material.diffuseColor = new Color3(1, 1, 1)
return material
}

async createObstacle (
async createObstacle(
name: string,
location: Vector3,
textureChoice: number,
Expand Down
6 changes: 4 additions & 2 deletions game_frontend/src/babylon/assetPacks/modern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,18 @@ export default class ModernAssetPack extends AssetPack {
const obstacle = await super.createObstacle(name, location, textureChoice, parent)
obstacle.material = this.obstacleMaterials[textureChoice - 1]
obstacle.rotate(Axis.Y, this.createRandomRotation(), Space.WORLD)
obstacle.scaling = new Vector3(0.75, 1.3, 0.48)
return obstacle
}

/**
* This function returns a random angle in radians
*
* @return {number} a random angle in radians, in increments of a quarter
* @return {number} a random angle in radians, in increments of half pi
*
*/

createRandomRotation(): number {
return Math.PI / (Math.floor(Math.random() * Math.floor(4)) + 1)
return (Math.PI * Math.floor(Math.random() * 4)) / 2
}
}
20 changes: 10 additions & 10 deletions game_frontend/src/babylon/entities/avatarManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Vector3,
ShaderMaterial,
Scene,
Color3
Color3,
} from 'babylonjs'
import { Environment } from '../environment/environment'
import { DiffItem } from '../diff'
Expand All @@ -28,7 +28,7 @@ export default class AvatarManager implements GameNode, DiffHandling {
importMesh: Function
shaderMaterial: ShaderMaterial

constructor (environment: Environment, importMesh: Function = SceneLoader.ImportMeshAsync) {
constructor(environment: Environment, importMesh: Function = SceneLoader.ImportMeshAsync) {
this.importMesh = importMesh
this.gameStateProcessor = new DiffProcessor(this)

Expand All @@ -41,7 +41,7 @@ export default class AvatarManager implements GameNode, DiffHandling {
this.setupShaderMaterial()
}

setupMarkerMaterial (): void {
setupMarkerMaterial(): void {
this.markerMaterial = new StandardMaterial('avatar marker', this.scene)
this.markerMaterial.diffuseTexture = new Texture(
'/static/babylon/models/avatar_marker_texture.png',
Expand All @@ -50,14 +50,14 @@ export default class AvatarManager implements GameNode, DiffHandling {
this.markerMaterial.specularColor = new Color3(0, 0, 0)
}

setupShaderMaterial (): void {
setupShaderMaterial(): void {
this.shaderMaterial = new ShaderMaterial(
'Avatar shader',
this.scene,
'/static/babylon/models/toonshader',
{
attributes: ['position', 'normal', 'uv'],
uniforms: ['world', 'worldView', 'worldViewProjection', 'view', 'projection']
uniforms: ['world', 'worldView', 'worldViewProjection', 'view', 'projection'],
}
)
this.shaderMaterial.setTexture(
Expand All @@ -66,14 +66,14 @@ export default class AvatarManager implements GameNode, DiffHandling {
)
}

remove (avatar: DiffItem): void {
remove(avatar: DiffItem): void {
const toDelete = this.avatarNode.getChildMeshes(true, function (node): boolean {
return node.name === `avatar: ${avatar.value.id}`
})
toDelete[0].dispose()
}

async add (avatar: DiffItem) {
async add(avatar: DiffItem) {
const { meshes } = await this.importMesh(
'avatar',
'/static/babylon/models/',
Expand All @@ -95,7 +95,7 @@ export default class AvatarManager implements GameNode, DiffHandling {
}
}

edit (avatar: DiffItem): void {
edit(avatar: DiffItem): void {
const avatarToAnimate = this.avatarNode.getChildMeshes(true, function (node): boolean {
return node.name === `avatar: ${avatar.value.id}`
})[0]
Expand All @@ -117,7 +117,7 @@ export default class AvatarManager implements GameNode, DiffHandling {
setOrientation(walkingAvatar, avatar.value.orientation)
}

async attachMarker (avatarMesh: any) {
async attachMarker(avatarMesh: any) {
const { meshes } = await this.importMesh(
'avatar_marker',
'/static/babylon/models/',
Expand All @@ -133,7 +133,7 @@ export default class AvatarManager implements GameNode, DiffHandling {
marker.position = new Vector3(0, MARKER_HEIGHT, 0)
}

setCurrentAvatarID (avatarID: number) {
setCurrentAvatarID(avatarID: number) {
this.currentAvatarID = avatarID
}
}
Loading