without using PYGAME design a basic game with python name Frogger or single player pong. maybe use turtle.
DO NOT USE PYGAME... no pygame.. please.. i really need your help
Try the below code hope it solves your query.
import simplegui
import random
WIDTH = 600
HEIGHT = 400
BALL_RADIUS = 20
PAD_WIDTH = 8
PAD_HEIGHT = 80
HALF_PAD_WIDTH = PAD_WIDTH / 2
HALF_PAD_HEIGHT = PAD_HEIGHT / 2
def ball_init(right):
global ball_pos, ball_vel
ball_pos,ball_vel= [0, 0], [0, 0]
if right == True:
ball_pos = [WIDTH / 2, HEIGHT / 2]
ball_vel = [random.randrange(2, 4), -random.randrange(1, 3)]
if right == False:
ball_pos = [WIDTH / 2, HEIGHT / 2]
ball_vel = [-random.randrange(2, 4), -random.randrange(1, 3)]
def new_game():
global paddle1_pos, paddle2_pos, paddle1_vel, paddle2_vel
global score1, score2
global score1_string, score2_string
score1_string = "0"
score2_string = "0"
paddle1_pos = [PAD_WIDTH / 2, HEIGHT / 2]
paddle2_pos = [WIDTH - PAD_WIDTH / 2, HEIGHT / 2]
paddle1_vel, paddle2_vel, score1, score2 = 0, 0, 0, 0
ball_init(True)
def limit():
global paddle1_pos, paddle2_pos, paddle1_vel, paddle2_vel
if paddle1_pos[1] < HALF_PAD_HEIGHT:
paddle1_pos[1] = HALF_PAD_HEIGHT
paddle1_vel = 0
elif paddle1_pos[1] > HEIGHT - HALF_PAD_HEIGHT:
paddle1_pos[1] = HEIGHT - HALF_PAD_HEIGHT
paddle1_vel = 0
if paddle2_pos[1] < HALF_PAD_HEIGHT:
paddle2_pos[1] = HALF_PAD_HEIGHT
paddle2_vel = 0
elif paddle2_pos[1] > HEIGHT - HALF_PAD_HEIGHT:
paddle2_pos[1] = HEIGHT - HALF_PAD_HEIGHT
paddle2_vel = 0
def draw(c):
global score1, score2, paddle1_pos, paddle2_pos, ball_pos,
ball_vel
global score1_string, score2_string
limit()
paddle1_pos[1] += paddle1_vel
paddle2_pos[1] += paddle2_vel
c.draw_line([WIDTH / 2, 0],[WIDTH / 2, HEIGHT], 1,
"White")
c.draw_line([PAD_WIDTH, 0],[PAD_WIDTH, HEIGHT], 1, "White")
c.draw_line([WIDTH - PAD_WIDTH, 0],[WIDTH - PAD_WIDTH, HEIGHT], 1,
"White")
pad1top = [paddle1_pos[0], paddle1_pos[1] - HALF_PAD_HEIGHT]
pad1bot = [paddle1_pos[0], paddle1_pos[1] + HALF_PAD_HEIGHT]
c.draw_line(pad1top, pad1bot, PAD_WIDTH, "White")
pad2top = [paddle2_pos[0], paddle2_pos[1] -
HALF_PAD_HEIGHT]
pad2bot = [paddle2_pos[0], paddle2_pos[1] + HALF_PAD_HEIGHT]
c.draw_line(pad2top, pad2bot, PAD_WIDTH, "White")
ball_pos[0] += ball_vel[0]
ball_pos[1] += ball_vel[1]
if ball_pos[1] <= BALL_RADIUS:
ball_vel[1] = - ball_vel[1]
if ball_pos[1] > (HEIGHT - 1 - BALL_RADIUS):
ball_vel[1] = - ball_vel[1]
if ball_pos[0] <= PAD_WIDTH + BALL_RADIUS:
if ( pad1top[1] <= ball_pos[1] <= pad1bot[1] ):
ball_vel[0] = - ball_vel[0] * 1.1
else:
ball_init(1)
score2 += 1
score2_string = str(score2)
if ball_pos[0] >= WIDTH - PAD_WIDTH - BALL_RADIUS:
if ( pad2top[1] <= ball_pos[1] <= pad2bot[1] ):
ball_vel[0] = - ball_vel[0] * 1.1
else:
ball_init(0)
score1 += 1
score1_string = str(score1)
c.draw_circle(ball_pos, BALL_RADIUS, 1, "White", "White")
c.draw_text(score2_string, (450, 50), 36, "White")
c.draw_text(score1_string, (150, 50), 36, "White")
def keydown(key):
acc = 1
global paddle1_vel, paddle2_vel
if key==simplegui.KEY_MAP["s"]:
paddle1_vel += acc
if key==simplegui.KEY_MAP["down"]:
paddle2_vel += acc
def keyup(key):
acc = 1
global paddle1_vel, paddle2_vel
if key==simplegui.KEY_MAP["w"]:
paddle1_vel -= acc
if key==simplegui.KEY_MAP["up"]:
paddle2_vel -= acc
def restart():
new_game()
def exit():
window.stop()
window = simplegui.create_frame("Single Pong", WIDTH, HEIGHT)
window.set_draw_handler(draw)
window.set_keydown_handler(keydown)
window.set_keyup_handler(keyup)
window.add_button("Want to Play Again?? CLick ME", restart,
100)
window.add_button("Click to EXIT",exit,100)
window.start()
new_game()
without using PYGAME design a basic game with python name Frogger or single player pong. maybe...
1. Use Turtle Graphics to create a tic tac toe game in Python. Write a Python program that allows for one player vs computer to play tic tac toe game, without using turtle.turtle
Software design [Singleton v.s. Static] You are producing a mobile game that allows both single player gameplayer and networked multiplayer gameplay. Your team is debating how you should approach the NetworkController, which is a single point of control for the game's network connections and traffic. The language you are using is C#. Sandy, the system analyst, believes that a Singleton pattern will be needed here Terence, the product manager, believes a static class is sufficient Please analyze the advantages and...
Using C++ Create a Blackjack program with the following features: Single player game against the dealer. Numbered cards count as the number they represent (example: 2 of any suit counts as 2) except the Aces which can count as either 1 or 11, at the discretion of the player holding the card. Face cards count as 10. Player starts with $500. Player places bet before being dealt a card in a new game. New game: Deal 2 cards to each...
Please help with this python turtle problem using the
functions provided.
Python Turtle Write a program using the turtle module to draw the face of a clock that looks like the image below. You will need to use the turtle module for this exercise as well as the bgcolor), shape(), color), penup), right(), forward(), pendown(), and stamp() functions. The code below can be removed or changed as needed. import turtle t turtle.Turtle0 t.forward(75)
1) A ping pong ball is drawn at random from an urn consisting of balls numbered 4 through 9. A player wins $1 if the number on the ball is odd and loses $1 if the number is even. Let x be the amount of money a player will win/lose when playing this game, where x is negative when the player loses money. (a) Construct the probability distribution table for this game. Round your answers to two decimal places. Outcome...
Please write the program in python: 3. Design and implement a simulation of the game of volleyball. Normal volleyball is played like racquetball, in that a team can only score points when it is serving. Games are played to 15, but must be won by at least two points. 7. Craps is a dice game played at many casinos. A player rolls a pair of normal six-sided dice. If the initial roll is 2, 3, or 12, the player loses....
python code( using functions please)! Rules of the game: - This game requires a dice. The goal of the game is to collect the correct number of coins to create a dollar. Players take coins based on a roll of the dice. The numbers on the dice correlate to the coin values as follows: 1—penny 2—nickel 3—dime 4—quarter 5— ( pick a random card from 1 to 4): o 1 = penny o 2 =...
Your task in to design a game of Nim in Python. In this game “Two players take turns removing objects from distinct heaps or piles. On each turn, a player must remove at least one object, and may remove any number of objects provided they all come from the same heap/pile. The goal of the game is to avoid taking the last object.” (Wikipedia) In your implementation of the game, there will be 3 piles of objects. At the start...
on python i need to code a guessing game. After the player has guessed the random number correctly, prompt the user to enter their name. Record the names in a list along with how many tries it took them to reach the unknown number. Record the score for each name in another list. When the game is quit, show who won with the least amount of tries. this is what i have so far: #Guess The Number HW assignment import...
Written in Python In this lab, you are to build a trivia game. The game should present each question – either in order or randomly – to the player, and display up to four possible answers. The player is to input what they believe to be the correct answer. The game will tell the player if they got it right or wrong and will display their score. If they got it right, their score will go up. If they got...