Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Poll

What programming topic would you want the next challenge to be about?  (It might be a good opportunity to focus on a subject you're not familiar with or to reinforce knowledge on one that you already know)

Control Flow
- 2 (2.2%)
Arrays, Strings, Pointers, and References
- 8 (9%)
Functions
- 4 (4.5%)
Basic object-oriented programming
- 30 (33.7%)
A bit more advanced OOP (Composition, Operator overloading, Inheritance, Virtual Functions)
- 18 (20.2%)
Templates
- 8 (9%)
Other (Explain)
- 4 (4.5%)
Working with files?  (Streams)
- 15 (16.9%)

Total Members Voted: 89


Pages: 1 ... 28 29 [30] 31 32 ... 78

Author Topic: Programming Challenges & Resources (#bay12prog) Initiative  (Read 95999 times)

ILikePie

  • Bay Watcher
  • Call me Ron
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #435 on: November 05, 2010, 04:02:48 pm »

Spoiler: *snip* (click to show/hide)
But it's late and I might be mistaken.
Sat down for another few hours today, yesterday, tried everything from OR to NOT, and I believe I've got it right. Here it is if anyone cares:
Spoiler (click to show/hide)
Logged

Mondark

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #436 on: November 06, 2010, 09:54:05 pm »

So, this thread and a few other factors finally convinced me to throw together a tech demo for an idea that's been floating around in my head a while.  Using Python, libtcod, and a decent tutorial I managed to obtain the following (spoilered for length):

You'll need libtcod and the libtcod python bindings (libtcodpy.py) to run it.
Arrow keys, or vi keys to move.
Spoiler (click to show/hide)

I may or may not take this farther, I don't want to do so without committing properly to it, and I'm not sure I've got the time to do so.
Thoughts?  Comments?

--EDIT--
Whoops, left out two rather important parts, sorry.
You'll need to put a libtcod font png file in the same directory.  Libtcod comes with a 'data/fonts' folder that has a bunch, I recommend one of the 10x10s.  Just put it next to the main file and rename it 'font.png'
You'll also need the following map file (map.txt):
Spoiler (click to show/hide)
« Last Edit: November 07, 2010, 07:39:34 am by Mondark »
Logged
Fefeshnelmargalip

lordnincompoop

  • Bay Watcher
  • Allusionist
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #437 on: November 07, 2010, 03:44:04 am »

Oh jeez how do you parse strings and make the IO stream dealio. I can make a text adventure, sure, but it'll consist of single-character commands and I'll have to use std::cin all the time. Not fun.
Logged

Argembarger

  • Bay Watcher
    • View Profile
    • Not quite yet
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #438 on: November 07, 2010, 04:44:35 am »

import mario
import bowser
import mushroom kingdom
import platforms
import kidnappedprincess

there you go, SMB in Python. I hope everyone's taking notes.
Logged
Quote from: penguinofhonor
Quote from: miauw62
This guy needs to write a biography about Columbus. I would totally buy it.
I can see it now.

trying to make a different's: the life of Columbus

lordnincompoop

  • Bay Watcher
  • Allusionist
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #439 on: November 07, 2010, 05:22:15 am »

Dammit, Python!  >:(
Logged

Berserker

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #440 on: November 09, 2010, 11:25:55 am »

Thoughts?  Comments?

It seems like a good start, I couldn't find any bugs.

Btw, you can replace this pile of If-statements
Code: [Select]
if   dir == Dirs.N:
    return (x,y-1)
elif dir == Dirs.NE:
    return (x+1,y-1)
elif dir == Dirs.E:
    return (x+1,y)
elif dir == Dirs.SE:
    return (x+1,y+1)
elif dir == Dirs.S:
    return (x,y+1)
elif dir == Dirs.SW:
    return (x-1,y+1)
elif dir == Dirs.W:
    return (x-1,y)
elif dir == Dirs.NW:
    return (x-1,y-1)
else:
    return (x,y)

with this:
Code: [Select]
dtx, dty = dirtoc[dir]
return (x+dtx, y+dty)

it takes less space and is more efficient (not significantly though)
Logged

eerr

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #441 on: November 09, 2010, 02:25:05 pm »

Oh jeez how do you parse strings and make the IO stream dealio. I can make a text adventure, sure, but it'll consist of single-character commands and I'll have to use std::cin all the time. Not fun.
What the hell is wrong with std::cin?

Just buffer the letters for the commands into a string.
Print everything in the buffer. (I believe \b will shorten a word by one leter, on a terminal-type connection)
and flush the buffer as a command, when 'return' or 'enter' is pressed.
Logged

lordnincompoop

  • Bay Watcher
  • Allusionist
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #442 on: November 09, 2010, 02:35:48 pm »

I'm confused. What do you mean?  ???
Logged

eerr

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #443 on: November 09, 2010, 03:48:52 pm »

One character commands? why?

and why is this a problem? a string word, or number can be written by a series of one-character commands just fine.

Logged

Mondark

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #444 on: November 09, 2010, 09:21:44 pm »

this:
Code: [Select]
dtx, dty = dirtoc[dir]
return (x+dtx, y+dty)

*facepalm*
That's exactly the sort of thing I made that dictionary for, stupid me.
*goes off to fix*
Logged
Fefeshnelmargalip

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #445 on: November 10, 2010, 12:32:10 pm »

Using C# for a rather large project, and something is bugging me. How does one tell the difference between the equivalent of a C++ value and a C++ pointer? Some code will have variable x = variable y and it works just like C++; that is, it copies the value from y to x. Whereas other code will have variable x = variable y act like variable x points to the memory location of variable y (and subsequent changes to y cause x to change). How do I tell which of the two actions it will do?
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #446 on: November 10, 2010, 02:38:23 pm »

C++ has no "variable".
So that's about the only security you get, AFAIK.
Usually it's like this: basic types are copied, objects are referred to. What defines a basic type is different per language, and objects may override their = operator to copy themselves instead of referring. How do you know? You could try ===, that does the job in a few languages.
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

Duelmaster409

  • Bay Watcher
  • [DOES_NOT_FIGHT]
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #447 on: November 11, 2010, 12:45:26 am »

Anyone here ever heard of Pygame? It's a game development library/platform for Python!
Logged
Dwarf fortress: Teaching uni level geology to sadistic elf killers for years.

Normandy

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #448 on: November 11, 2010, 02:09:20 pm »

C#:

Two types: Classes, Structs

Classes are always passed by reference
Structs are always passed by value

Standard C# is that structs are lowercase, classes are uppercase.
Logged

lordnincompoop

  • Bay Watcher
  • Allusionist
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #449 on: November 15, 2010, 04:50:32 pm »

Gah! I'm trying to tame the beast that is GURPS 4ed into some sort of easy, understandable game form but it's rather hard.

Oh, and what do the +=, -= *= and /= operators do?
« Last Edit: November 15, 2010, 05:04:17 pm by lordnincompoop »
Logged
Pages: 1 ... 28 29 [30] 31 32 ... 78