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 ... 75 76 [77] 78

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

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #1140 on: October 14, 2011, 01:32:27 pm »

Argument gp, or "the player".
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))

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #1141 on: October 14, 2011, 01:33:16 pm »

but is't your complain that is isn't centering on it?

* Japa is confused.
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #1142 on: October 14, 2011, 01:45:22 pm »

Oh that's what you mean :)

Well, if I move around, the window moves, too, but at a higher/slower rate than the player. Then it suddenly starts jumping all over the place...

This is what I use to get the location from grid to screen, and from screen to grid: ty and tx are graphic-offsets and zero for this purpose, 32 is tile width.
Code: [Select]
    public Vec3 getScreenLoc(float x, float y, float z, float tx, float ty){
    return (new Vec3((int)(tx-viewPortX +(32*(x-y)/2)), (int)(ty-viewPortY +(32*((x+y)/2))/2), 0));
    }
    public Vec3 getRealLoc(float u, float v) {
   
    float x = -(2*viewPortY+viewPortX-2*v-u)/32;
    float y = -(2*viewPortY-viewPortX-2*v+u)/32;
    return (new Vec3(x,y,0));
    }

See: http://nam.siquo.net/webgames/lets-dev/, controls are WESD.
Hold D for long enough and the viewport should catch up to the actual playerperson.
« Last Edit: October 14, 2011, 01:50:27 pm by Siquo »
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))

eerr

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #1143 on: October 14, 2011, 04:56:01 pm »

I think you need to make hordes and hordes of constants so you, and us have to deal with less highly-complicated math.
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #1144 on: October 14, 2011, 04:57:34 pm »

BUT THIS IS THE SIMPLE PART and my brain is getting more stupid by the day. 10 yrs ago this would've been easy.
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))

eerr

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #1145 on: October 14, 2011, 09:51:38 pm »

Then make a diagram to help with the map.

needs a tilted iso map.

box defining camera.

labeled axis.

some points for reference.
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #1146 on: October 15, 2011, 12:27:32 pm »

I got nothing, I slam my head against the keyboard until it works. But that might just be a good idea :)
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))

TolyK

  • Bay Watcher
  • Nowan Ilfideme
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #1147 on: October 15, 2011, 01:55:55 pm »

Alright.
http://www.bay12forums.com/smf/index.php?topic=64473.0
Wanting to get this to work with the lastest DF. :P
How should I go about this?
(Related note: where to get the older version for it? :P)
Logged
My Mafia Stats
just do whatevery tolyK and blame it as a bastard mod
Shakerag: Who are you personally suspicious of?
At this point?  TolyK.

Thendash

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #1148 on: October 15, 2011, 01:57:07 pm »

You're passing a GamePhysical object to getScreenLoc, but then in the code you posted it accepts 5 floats. I'm assuming you overloaded the function, can you post the code that only takes gp? I think eerr is right, it's probably a mistake somewhere in the math.
Logged
Thendash's Livestream

This game could honestly give out hand jobs for free and people would still bitch.

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #1149 on: October 15, 2011, 05:19:51 pm »

I got nothing, I slam my head against the keyboard until it works. But that might just be a good idea :)
Whenever I hit a roadblock, it often helps me to write (or in your case rewrite) the solution not as what you want the computer to do, but more like an explanation to a person (as far as the syntax allows it of course). So instead of  (warning, Lost In Superfluous Parenthesis-syndrom possible)
Code: [Select]
(case (get-button)
  (1 (setf (x player) (1+ (x player))) ;Could've used incf and decf here, but this is probably easier to understand for you
  (2 (setf (x player) (1- (x player))))
I'd write
Code: [Select]
(on-button-press
  (right (move player right))
  (left (move player left)))
Or even
Code: [Select]
(on-key-press
  ((direction-key-p key) (move player (direction key)))) ;Using the -p suffix for a predicate function, which is a function that checks a property and returns a boolean
and then worry about the exact implementation of in this case on-button-press and move (note that the last one may not be translatable into a language that lacks macros). This way, you build yourself a set of operations that can be used to write code in a much more legible way, which then helps with debugging and makes it easier to write new code. In your example, a line like (2*viewPortY+viewPortX-2*v-u)/32; makes me shudder, because it's error-prone and hard to read. If you'd split off those math operations into seperate functions and rigorously test them you'd probably find the bug rather quick.
« Last Edit: October 15, 2011, 05:27:46 pm by Virex »
Logged

eerr

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #1150 on: October 15, 2011, 07:37:18 pm »

It should be noted I made something similar for my brother, to align pictures in his iphone game.


If the camera's edge would travel beyond the corner of the iso map,
It must be forced back,(hard limit.)


If camera's left side.x<corner of isomap.left.x,  Camera center.x= camerawidth/2 +corner of isomap.leftside.x

Four of these to make sure the camera doesn't  scroll off the side.

The pluses and minuses change haphhazardly.

"corner of isomap.leftside.x" because the x location or y location of the corner of a tile is not the same as it's raw coordinate. But you could get away with just the raw position because nobody cares.




As the player moves about, the camera otherwise centers on the player.
(this is the simple part.)

Though for whatever reason, In your math, the camera Accelerates toward the player.
Odd, but it works(and allows you to actually get something done with terrible camera alignments!).

Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #1151 on: October 17, 2011, 01:20:37 pm »

My way of doing math is Darwinistic:

1. Make shit up.
2. Test it against the situation I want it to work for. Not quite done? Goto 3.
3. Randomly add/remove actions (add, multiply, etc) and constants.
4. Goto 2.
5. Profit.

This yields me results that nobody understands but work for the current parameters, but as soon as I want to use it for something it hasn't been tested for, it fails and I need to restart the process, taking the new situation into account. I also never get profit.


Damnit, this means I actually have to think about this. :(
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))

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #1152 on: October 17, 2011, 06:47:52 pm »

hmm, that would explain why I've got a hard time following your code...
Also, you sound like an anthropomorphic version of eureqa, eureqa-san so to say :P
« Last Edit: October 17, 2011, 06:49:30 pm by Virex »
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #1153 on: October 18, 2011, 10:32:28 am »

Yeah something like that. Genetic algorithms have that tendency. There was once this self-reconfiguring lego-block-assembly thing that assembled into something that performed, but the creators didn't know how it did it, as it wasn't supposed to (they found out much much later there was a short circuit in one of the blocks that is was using as a feature instead of a bug).

Okay, redoing the math on paper this time.
Grid-to-Screen:
X = x-y (and some constants)
Y = (x+y)/2  (and some constants)

Screen-to-Grid:
x = (2Y+X)/2
y = (2Y-X)/2
(and some constants)

This is about what I have. Hmm, I think that's correct. So it must be the viewport code. I'll try something tonight.
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))

SolarShado

  • Bay Watcher
  • Psi-Blade => Your Back
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #1154 on: October 18, 2011, 12:09:42 pm »

One odd bit that I noticed:
You seem to include the current viewport location in the calculations for the new position. This means where the viewport ends up is relative to where it started, which I doubt you want.
Logged
Avid (rabid?) Linux user. Preferred flavor: Arch
Pages: 1 ... 75 76 [77] 78