Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
47 changes: 31 additions & 16 deletions CMPUT 250 W24 Lab 3/Assets/DVDLogo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,34 @@ public class DVDLogo : MonoBehaviour
//Current direction
private Vector3 direction;

// Axis of rotation
public Vector3 spinAxis = new Vector3(0, 1, 0);

// Speed of rotation in degrees per second
public float spinSpeed = 50f;

// Start is called before the first frame update
void Start()
{
//Randomly initialize direction
direction = new Vector3(Random.Range(-1f,1f), Random.Range(-1f,1f));
direction = new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f));
direction.Normalize();

}

private void FlipDirectionX(){
direction.x*=-1;
direction.x+= Random.Range(-0.1f,0.1f);
direction.y+= Random.Range(-0.1f,0.1f);
private void FlipDirectionX()
{
direction.x *= -1;
direction.x += Random.Range(-0.1f, 0.1f);
direction.y += Random.Range(-0.1f, 0.1f);
direction.Normalize();
}

private void FlipDirectionY(){
direction.y*=-1;
direction.x+= Random.Range(-0.1f,0.1f);
direction.y+= Random.Range(-0.1f,0.1f);
private void FlipDirectionY()
{
direction.y *= -1;
direction.x += Random.Range(-0.1f, 0.1f);
direction.y += Random.Range(-0.1f, 0.1f);
direction.Normalize();
}

Expand All @@ -41,24 +49,31 @@ void Update()
{
//Move in direction unless we'd go out of bounds, if so bounce with some randomness

Vector3 newPosition = transform.position + direction*Time.deltaTime*speed;
Vector3 newPosition = transform.position + direction * Time.deltaTime * speed;

//See if a bounce needs to happen before moving
if (newPosition.x>X_Max){
if (newPosition.x > X_Max)
{
FlipDirectionX();

}
else if (newPosition.x<-1*X_Max){
else if (newPosition.x < -1 * X_Max)
{
FlipDirectionX();
}

if (newPosition.y>Y_Max){
if (newPosition.y > Y_Max)
{
FlipDirectionY();
}
else if (newPosition.y<-1*Y_Max){
else if (newPosition.y < -1 * Y_Max)
{
FlipDirectionY();
}

transform.position += direction*Time.deltaTime*speed;

transform.Rotate(spinAxis * spinSpeed * Time.deltaTime);

transform.position += direction * Time.deltaTime * speed;
}
}
Binary file added CMPUT 250 W24 Lab 3/Assets/IMG_7530.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions CMPUT 250 W24 Lab 3/Assets/IMG_7530.JPG.meta

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

94 changes: 90 additions & 4 deletions CMPUT 250 W24 Lab 3/Assets/Scenes/SampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Transform:
m_Children:
- {fileID: 755472558}
m_Father: {fileID: 0}
m_RootOrder: 1
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &421997422
MonoBehaviour:
Expand All @@ -168,6 +168,8 @@ MonoBehaviour:
speed: 3
X_Max: 5
Y_Max: 4
spinAxis: {x: 0, y: 1, z: 0}
spinSpeed: 50
--- !u!1 &519420028
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -203,7 +205,7 @@ Camera:
m_GameObject: {fileID: 519420028}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
Expand Down Expand Up @@ -321,7 +323,7 @@ SpriteRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 6e7069a7db07f489a87c0797b3ff2165, type: 3}
m_Sprite: {fileID: 21300000, guid: 5b2adecb658aa254b9e7cf5e14b9bc83, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
Expand Down Expand Up @@ -497,6 +499,87 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &1534739414
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1534739416}
- component: {fileID: 1534739415}
m_Layer: 0
m_Name: IMG_7530
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!212 &1534739415
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1534739414}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: -1
m_Sprite: {fileID: 21300000, guid: 809b0cb3569eafd44ac6fa96bc8f3641, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 30.24, y: 40.319996}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!4 &1534739416
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1534739414}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2098954801
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -566,7 +649,10 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: This is a bouncing ball
m_Text: 'Graphic design is my passion


'
--- !u!222 &2098954804
CanvasRenderer:
m_ObjectHideFlags: 0
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading