Skip to content

Commit

Permalink
032
Browse files Browse the repository at this point in the history
  • Loading branch information
0xjaqbek committed Jul 10, 2024
1 parent 77c861f commit d9ed720
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
25 changes: 19 additions & 6 deletions src/IndexPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ const IndexPage: FC = () => {
const [showInstructions, setShowInstructions] = useState(true);
const [gameStarted, setGameStarted] = useState(false);
const [carAnimation, setCarAnimation] = useState('');
// const [showPowerIndicator, setShowPowerIndicator] = useState(false);
// const [powerIndicatorValue, setPowerIndicatorValue] = useState(0);


useEffect(() => {
if (gameStarted) {
Expand Down Expand Up @@ -142,14 +141,28 @@ const handleGearClick = () => {
borderRadius: '5px',
zIndex: 4,
position: 'absolute',
top: '35%',
top: '5%',
left: '50%',
transform: 'translateX(-50%)',
}}>
Elapsed Time: {elapsedTime.toFixed(2)} seconds<br></br>
<StyledButton onClick={() => window.location.reload()} style={{ margin: '20px', cursor: 'pointer' }}>
Restart Race
</StyledButton>
<StyledButton onClick={() => {
setPosition1(0);
setPosition2(RESET_POSITION);
setClickCount(0);
setMoveDistance(INITIAL_MOVE_DISTANCE);
setShowGear(false);
setShowingImage('');
setClickEnabled(false);
setStartTime(0);
setEndTime(0);
setVerticalBlurLevel(0);
setShowInstructions(true);
setGameStarted(false);
setCarAnimation('');
}} style={{ margin: '20px', cursor: 'pointer' }}>
Restart
</StyledButton>
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/PowerIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const powerImages = [

const PowerContainer = styled.div`
position: absolute;
top: 5px;
top: 5%;
left: 10px;
z-index: 4; /* Ensure it's above other elements */
`;
Expand Down
12 changes: 9 additions & 3 deletions src/ProgressIndicator.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// ProgressIndicator.tsx
import React, { FC } from "react";
import { FC } from "react";
import styled from "styled-components";

const ProgressWrapper = styled.div`
Expand All @@ -15,6 +14,10 @@ const ProgressWrapper = styled.div`
font-size: 28px;
`;

const LargeNumber = styled.span`
font-size: 56px; // 2x larger
`;

interface ProgressIndicatorProps {
clickCount: number;
}
Expand All @@ -30,9 +33,12 @@ const ProgressIndicator: FC<ProgressIndicatorProps> = ({ clickCount }) => {
return "7/7";
};

const progress = calculateProgress(clickCount);
const [largeNumber, smallNumber] = progress.split("/");

return (
<ProgressWrapper>
{calculateProgress(clickCount)}
<LargeNumber>{largeNumber}</LargeNumber>/{smallNumber}
</ProgressWrapper>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/speed.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// newLogic.ts
export const MAX_SPEED = 25; // Maximum move distance in pixels per click
export const RESET_POSITION = -650; // Height of road image (in pixels)
export const MAX_SPEED = 55; // Maximum move distance in pixels per click
export const RESET_POSITION = -600; // Height of road image (in pixels)

export const calculateMoveDistance = (clickCount: number): number => {
const increment = MAX_SPEED * 0.01449; // 1.44% of max speed
Expand Down
Binary file modified src/ulica.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d9ed720

Please sign in to comment.