Page 1 of 1

Begining programming

PostPosted: Sat Jan 12, 2008 7:51 pm
by mac9416
I have nearly NO programming experience (unless you consider QBasic to be valid programming experience :oops: ) 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.

Re: Begining programming

PostPosted: Mon Jan 14, 2008 10:02 am
by TheeMahn
mac9416 wrote:I have nearly NO programming experience (unless you consider QBasic to be valid programming experience :oops: ) 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.



I would suggest C, it is an all around good language for doing anything, I will forewarn you it will be quite difficult to learn now that you know basic, I bought a book "learn C in 14 days", a total waste... Chapter 1 said if you know visual basic you may as well hang it up now, it will be tremendously difficult to learn as you will compare basic to C.

It did indeed take me a long time to learn C, ASM was the hardest language I have ever learned I suggest staying away from it it is faster then C, but make a mistake there and it will lock up your system losing your code since your last save at least that was the way it was back in the the Commodore 64 days, been a long time since I used it obviously, but still remember #C000 in hex = 49152 in decimal which is the address I did most of my programming.

There are many websites that teach programming in C can you say "Hello World" Google it ;)

Wish you the best of luck and look forward to seeing some of your work here.

Best regards,

TheeMahn

Re: Begining programming

PostPosted: Mon Jan 14, 2008 5:48 pm
by mac9416
TheeMahn,

Thanks for the advice.
I have TRIED to read a C book, but it boggled my mind. :ugeek: :cry: I have read a little bit about Pygame and it looks like fun. However, I will try to break the ice and learn C. The only problem that I had when I read the book was that It didn't talk about how to display the "eye candy". I'll keep looking.
Thank you. You're Thee Mahn ;)

Yours truly,
Mac

Re: Begining programming

PostPosted: Sat Jan 26, 2008 7:35 pm
by mac9416
Well, I got a few Pygame Howtos and a simple bouncing ball animation:
Code: Select all
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()


and turned it into this (very) primitive Pong game. It just shuts down when you miss the ball and sometimes the ball just flies right through the paddle. Other than that it's a great game! ;)

Code: Select all
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()


Not very good but fun to look at. I hope everyone has either a good time or a few laughs with it ;) . Just remember, I'm a noob. :geek:

Re: Begining programming

PostPosted: Sat Feb 02, 2008 1:12 am
by aperrigo
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.

Re: Begining programming

PostPosted: Sat Feb 02, 2008 9:22 pm
by mac9416
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.


I wish I could help ,aperrigo, but it looks like you know more about programming than I am likely to for a long time. Maybe TheeMahn will stop by here and help you out. :)

ps: I see your from Tennessee. Glad I'm not alone. :D ;)

Re: Begining programming

PostPosted: Sat Feb 02, 2008 10:08 pm
by cowboy
Hello here are a few starts, google is a warehouse full of info.. :) here,, http://www.programmingtutorials.com/javascript.aspx and another http://www.hitmill.com/programming/cpp/cpp.html and one I can read good..large fonts.. http://www.stat.rice.edu/~helpdesk/howto/cshell.html this will keep you busy, and good luck on your endeavours. ;)

Re: Begining programming

PostPosted: Sun Feb 10, 2008 7:09 pm
by mac9416
I use a simple clock desklet that looks easy to mod maybe. It looks like it's in Python, which I know a very little bit about. Any tips? Wish me luck. :lol:

Re: Begining programming

PostPosted: Sat Feb 16, 2008 6:42 pm
by mac9416
Hello everybody,
I think I may have broke Google's server :lol: . Yet, I still can't seem to find out how to program 2D games with c/c++ though. I am pretty sure that Freeciv is done in c++. Why can't I make a game that has "eye candy" too, instead of the boring ole' "hello world" type program. I'm confused. A little help.
Thanks for hangin' in there with me.