Jump to content
  • Advertisement

Oysterman

Member
  • Content Count

    17
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Oysterman

  • Rank
    Member
  1. Oysterman

    The State Pattern

    Antheus: that looks more like the "Strategy" pattern to me, am I right?
  2. Oysterman

    Mapping database objects to code?

    I believe what you're looking for is an Object-Relational Mapper (ORM). I don't know what's available for .NET, but Google may help you with that.
  3. Oysterman

    Extract int from string in Java

    Quote:Original post by kevin_06s I figured it out. The problem was that I had to do: sum += Math.pow(Integer.parseInt(Character.toString(temp.charAt(n))), 4); It seems like this would be so much easier in other languages. I think C++ would just be sum = pow(temp[n] - '0', 4); Java sucks, but maybe not as much as you may think. :) You can do basically the same thing in Java too, as: import static java.lang.Math.*; // ... sum += pow(temp.charAt(n) - '0', 4); And the loop could be made more readable (though not necessarily more efficient) with: import static java.lang.Math.*; // ... for (char c : temp.toCharArray()) { sum += pow(c - '0', 4); } Phresnel does have a point, though.
  4. Oysterman

    [C++] Coding Styles

    Quote:Original post by Grafalgar The trouble comes in with code that's not consistent. Ex: *** Source Snippet Removed *** That is headache inducing. Especially if you expand that out to a game/application hundreds of thousands of lines in size. Nothing inconsistent about that. Function/method definition -> opening brace on new line. Blocks inside a function (for, if, while...) -> opening brace on same line. Simple rule, don't you think? :)
  5. Oysterman

    Super Mario World (96 levels?)

    There are in fact not 96 levels, but 96 exits. I found them all back in the day - with help mind you, there were a couple (3 or 4, I think) that I never would have found on my own.
  6. Oysterman

    NullPointerException[ JAVA ]

    Well, obviously _children is null. I can't see you initializing the variable anywhere, and as long as you don't do that, it will be null. You need something like: private DoubleList<TreeNode<Type>> _children = new DoubleList<TreeNode<Type>>();
  7. Hi all, Long story short, I'm exploring wxPython, and I want to make it possible for a user to drag panels around in a Frame using the mouse. My spontaneous approach was to do something like this: import wx class Draggable(wx.Panel): def __init__(self, parent, size): wx.Panel.__init__(self, parent, size=size) self.SetBackgroundColour(wx.BLACK) self.Bind(wx.EVT_LEFT_DOWN, self.OnClick) self.Bind(wx.EVT_LEFT_UP, self.OnRelease) self.Bind(wx.EVT_MOTION, self.OnMouseMove) def OnClick(self, e): self.clickDelta = e.GetPositionTuple() self.oldPos = self.GetPositionTuple() self.SetBackgroundColour(wx.WHITE) self.Refresh() def OnRelease(self, e): # self.SetPosition(self.oldPos) self.SetBackgroundColour(wx.BLACK) self.Refresh() def OnMouseMove(self, e): if e.Dragging(): dx, dy = self.clickDelta mx, my = e.GetPositionTuple() x,y = self.GetPositionTuple() x += mx-dx y += my-dy self.SetPosition((x,y)) self.Refresh() class Frame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1) sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) d = Draggable(self, (50, 50)) d.SetPosition((50, 50)) class App(wx.App): def OnInit(self): f = Frame() self.SetTopWindow(f) f.Show() return True app = App(0) app.MainLoop() However, this approach makes it possible for the user to drag the things around faster than the event handling seems to be able to cope with. If you drag fast enough, you can make the mouse leave the panel while dragging it, messing everything up. I figure I could create a specific Panel class that functions as a container for Draggables. I'd register a Draggable with this container, and process the EVT_MOTION events in the container rather than in the individual Draggables. I like the first approach a lot better though, and I've successfully implemented it before in a similar way in Java/Swing. Is there a way I can make the first approach work well in wxPython?
  8. Oysterman

    Rate your math skills from 1 - 10

    Solve this and you're a 10 in my book: http://en.wikipedia.org/wiki/Hodge_conjecture If you understand half of it, you're an 8. :-) I teach mathematics in high school. I would not rate myself any higher than 3. And I really don't need to be half as good as I am to do my job well.
  9. Oysterman

    can't get swing gui to render...

    AFAIK all Swing components get the default width and height of 0, so you'd have to manually set the sizes of buttons, textfields and what have you. Normally the layout manager does this for you, but since the container (the panel) has none... :-) I believe that the default layout manager is a horizontally-aligned FlowLayout. This means that manually changing your bg panel's size does nothing, since the frame's layout manager has the final word anyway. I don't think that null layouts are deprecated. They're not recommended, but that's not the same thing. :-)
  10. Oysterman

    can't get swing gui to render...

    It could be that your bg JPanel maintains its default width and height of 0. Since there is no layout manager for the frame, there is nothing that tells the panel how big it should be. And don't set the layout manager of the frame to null - set the panel's layout to null, and place all components on the panel where you want them. Rip-off: in more recent versions of Java, no runtime error is thrown. Java has changed quite a lot since 1.4. :)
  11. Oysterman

    Java ArrayList question

    Quote:Original post by rip-off And finally I believe you might be able to change the type of 'arr' ArrayList<int> and let autoboxing handle this for you. Maybe not. Close. :) ArrayList<Integer> arr = new ArrayList<Integer>(); arr.add(2); System.out.println(arr.get(0) < 3); int val = arr.get(0); System.out.println(val);
  12. Oysterman

    Awesome Turn-Based Strategy Games?

    Jagged Alliance 2. I don't want to think about how many hours I've spent playing that game...
  13. Awesome stuff. I still remember some prices from an old computer parts catalogue I browsed through when I was a kid, back in 1993 I think... today you can get 4 GB RAM for the price of 1 MB back then.
  14. Oysterman

    Can you give me some hints to solve this?

    Quote:Original post by Raghar second round Superpig gaiiden Myopic Rhino Oluseyi But it could just as well be: Superpig Myopic Rhino gaiiden Oluseyi ...right? I easily got to the point where I only had to decide who came in 2nd and 3rd in the bike race, but then I was lacking information. As far as I can see there is no single, unique solution to this, am I right?
  15. Oysterman

    Best Windows OS for a new Mac?

    Quote:Original post by Trapper Zoid I know; that's part of my concern. The prices seem pretty steep for both Windows XP and Vista. The OEM discount is quite considerable. Money is always part of the issue; I feel somewhere between A$100-$200 is okay for a Windows OS, but prices of A$400 is a bit too pricey. But I'm not sure if Windows will be discounted enough for it be worth it. From what I understand, if you could buy from Amazon.com, Vista Home Premium + shipping would be around $240 AUD. (XP Home a little less, XP Pro a bit more.) Although I'm not sure Amazon.com will ship software to Australia, and I don't know whether there'd be any additional fees involved for you (import taxes, VAT, etc.).
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!