diff --git a/FunnyCatchGame.java b/FunnyCatchGame.java new file mode 100644 index 000000000..d17dc7914 --- /dev/null +++ b/FunnyCatchGame.java @@ -0,0 +1,99 @@ +package space; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.Random; + +public class FunnyCatchGame extends JPanel implements ActionListener { + private Timer timer; + private ArrayList items; + private int playerX = 250; + private final int playerWidth = 70; + private final int playerHeight = 20; + private int score = 0; + + public FunnyCatchGame() { + timer = new Timer(20, this); + items = new ArrayList<>(); + setFocusable(true); + addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_LEFT) { + playerX -= 10; + } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { + playerX += 10; + } + playerX = Math.max(0, Math.min(playerX, 500 - playerWidth)); + } + }); + timer.start(); + spawnItems(); + } + + private void spawnItems() { + Timer itemTimer = new Timer(1000, e -> { + Random rand = new Random(); + int x = rand.nextInt(850); + String itemType = rand.nextBoolean() ? "🦆" : "🌮"; + items.add(new Item(x, 0, itemType)); + }); + itemTimer.start(); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + g.setColor(Color.GREEN); + g.fillRect(playerX, 450, playerWidth, playerHeight); + g.setColor(Color.RED); + for (Item item : items) { + g.drawString(item.type, item.x, item.y); + } + g.setFont(new Font("Arial", Font.BOLD, 20)); + g.drawString("Score: " + score, 10, 20); + } + + @Override + public void actionPerformed(ActionEvent e) { + for (int i = 0; i < items.size(); i++) { + Item item = items.get(i); + item.y += 5; // Fall speed + if (item.y > 500) { + items.remove(i); + i--; + } else if (item.y >= 450 && item.x >= playerX && item.x <= playerX + playerWidth) { + // Catching the item + score += item.type.equals("🦆") ? 1 : 2; // Duck = 1 point, Taco = 2 points + items.remove(i); + i--; + } + } + repaint(); + } + + public static void main(String[] args) { + JFrame frame = new JFrame("Funny Catch Game"); + FunnyCatchGame game = new FunnyCatchGame(); + frame.add(game); + frame.setSize(500, 500); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setVisible(true); + } + + class Item { + int x, y; + String type; + + Item(int x, int y, String type) { + this.x = x; + this.y = y; + this.type = type; + } + } +} diff --git a/README.md b/README.md index 1daffed71..a122ac077 100644 --- a/README.md +++ b/README.md @@ -1,95 +1,69 @@ readme-banner -# [Project Name] 🎯 +# [Duck and Dock] 🎯 ## Basic Details -### Team Name: [Name] +### Team Name: [DevelopMental] ### Team Members -- Team Lead: [Name] - [College] -- Member 2: [Name] - [College] -- Member 3: [Name] - [College] +- Team Lead: [Kevin B John] - [College of engineering perumon] +- Member 2: [Hiba P N] - [College of engineering perumon] + ### Project Description -[2-3 lines about what your project does] +[Its a simple game to based on java.] ### The Problem (that doesn't exist) -[What ridiculous problem are you solving?] +[There are a lot of games, i just want to enjoy some time making my own version , or would i say i didnt like most the designs of such games :] ### The Solution (that nobody asked for) -[How are you solving it? Keep it fun!] +[Created a fun game in java, theres a lot of games there in the internet, adding my own pile to the ocean , or should i say its useless :)] ## Technical Details ### Technologies/Components Used For Software: -- [Languages used] -- [Frameworks used] -- [Libraries used] -- [Tools used] +- [java] +- [jdk IDE] + -For Hardware: -- [List main components] -- [List specifications] -- [List tools required] ### Implementation -For Software: -# Installation -[commands] +For Software: Eclipse IDE -# Run -[commands] -### Project Documentation -For Software: - -# Screenshots (Add at least 3) +# Screenshot![Screenshot 2024-10-26 091235](https://github.com/user-attachments/assets/5ae08857-da29-424c-9929-31aa6373b8d8) +s (Add at least 3) ![Screenshot1](Add screenshot 1 here with proper name) *Add caption explaining what this shows* ![Screenshot2](Add screenshot 2 here with proper name) -*Add caption explaining what this shows* +*Add caption ex![Screenshot 2024-10-26 091251](https://github.com/user-attachments/assets/c0a58390-a9a4-4635-acbf-389b2846a65a) +plaining what this shows* -![Screenshot3](Add screenshot 3 here with proper name) +![Screenshot3![Screenshot 2024-10-26 091335](https://github.com/user-attachments/assets/b9384fc5-7e3b-4d61-84f1-2fefb47ecd79) +](Add screenshot 3 here with proper name) *Add caption explaining what this shows* # Diagrams ![Workflow](Add your workflow/architecture diagram here) *Add caption explaining your workflow* -For Hardware: - -# Schematic & Circuit -![Circuit](Add your circuit diagram here) -*Add caption explaining connections* +### Project Demo +# Video -![Schematic](Add your schematic diagram here) -*Add caption explaining the schematic* +https://github.com/user-attachments/assets/713bf604-988c-41a9-bd3e-ed338664f840 -# Build Photos -![Components](Add photo of your components here) -*List out all components shown* -![Build](Add photos of build process here) -*Explain the build steps* +[Add your demo video link here] -![Final](Add photo of final product here) -*Explain the final build* -### Project Demo -# Video -[Add your demo video link here] -*Explain what the video demonstrates* -# Additional Demos -[Add any extra demo materials/links] ## Team Contributions -- [Name 1]: [Specific contributions] -- [Name 2]: [Specific contributions] -- [Name 3]: [Specific contributions] +- [HIBA P N]: [IDEA And support] +- [KEVIN B JOHN]: [IMPLEMENTATION] --- Made with ❤️ at TinkerHub Useless Projects