![Embarrassed :oops:](./images/smilies/icon_redface.gif)
Thanks ahead of time.
mac9416 wrote:I have nearly NO programming experience (unless you consider QBasic to be valid programming experience) but I would like to make my own 2D games. I could use some suggestions for language(s) that might work for me, and maybe a few good Wikis or books to check out.
Thanks ahead of time.
import sys, pygame
pygame.init()
size = width, height = 320, 240
speed = [2, 2]
black = 0, 0, 0
screen = pygame.display.set_mode(size)
ball = pygame.image.load("ball.bmp")
ballrect = ball.get_rect()
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
ballrect = ballrect.move(speed)
if ballrect.left < 0 or ballrect.right > width:
speed[0] = -speed[0]
if ballrect.top < 0 or ballrect.bottom > height:
speed[1] = -speed[1]
screen.fill(black)
screen.blit(ball, ballrect)
pygame.display.flip()
import sys, pygame
pygame.init()
size = width, height = 1000, 800
speed = [5, 5]
black = 0, 0, 0
screen = pygame.display.set_mode(size)
mouseposseccond = [0, 0]
mousemove = [0, 0]
ball = pygame.image.load("ball.png")
ballrect = ball.get_rect()
paddle = pygame.image.load("paddle.png")
paddlerect = paddle.get_rect()
paddlerect = paddlerect.move(0, height - 40) # Moves the paddle to just above the bottom of the screen.
while mouseposseccond < 1: # Finds the position of the cursor to mstart the game
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
mouseposseccond = pygame.mouse.get_pos()
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
# The following lines start with the position of the cursor
# at the beginning of the loop....
mouseposfirst = pygame.mouse.get_pos()
mousemove[0] = mouseposfirst[0] - mouseposseccond[0]
mousemove[1] = mouseposfirst[1] - mouseposseccond[1]
# ....And finishes with the difference between where the cursor was and
# where it now is.
paddlerect = paddlerect.move(mousemove[0], 0) # Moves the paddle on one axis(horizontal).
ballrect = ballrect.move(speed)
if ballrect.left < 0 or ballrect.right > width:
speed[0] = -speed[0]
if ballrect.top < 0:
speed[1] = -speed[1]
if ballrect.top > height:
sys.exit()
if paddlerect.top == ballrect.bottom and paddlerect.left < ballrect.right and paddlerect.right > ballrect.left: # IE "If the ball is in the middle of the paddle"
speed[1] = -speed[1]
# This next line is just in case the programming doesn't catch that
# the ball has actually hit the paddle. (It has happened to me)
if paddlerect.bottom == ballrect.bottom and paddlerect.left < ballrect.right and paddlerect.right > ballrect.left:
speed[1] = -speed[1]
mouseposseccond = mouseposfirst
screen.fill(black)
screen.blit(ball, ballrect)
screen.blit(paddle, paddlerect)
pygame.display.flip()
aperrigo wrote:I have a request...This week in my ASP.NET class I am working on debugging...but I had a terrible time with coding session-states that stored information into a public class ...and later when revisiting/refreshing/or posting back to that page reloading that same said information back into appropriate locations...ie. like a person's name within the name textbox.
My request is: besides the MSDN websites...where is some other sites. or sources of information that would give me better examples then my VB, C#, C++ , and ASP books.
Users browsing this forum: No registered users and 6 guests