Search Results

Search found 177 results on 8 pages for 'oscar godson'.

Page 6/8 | < Previous Page | 2 3 4 5 6 7 8  | Next Page >

  • keyDown works but i get beeps

    - by Oscar
    I just got my keydown method to work. But i get system beep everytime i press key. i have no idea whats wrong. Googled for hours and all people say is that if you have your keyDown method you should also implement the acceptsFirstResponder. did that to and it still doesn't work. #import <Cocoa/Cocoa.h> #import "PaddleView.h" #import "BallView.h" @interface GameController : NSView { PaddleView *leftPaddle; PaddleView *rightPaddle; BallView * ball; CGPoint ballVelocity; int gameState; int player1Score; int player2Score; } @property (retain) IBOutlet PaddleView *leftPaddle; @property (retain) IBOutlet PaddleView *rightPaddle; @property (retain) IBOutlet BallView *ball; - (void)reset:(BOOL)newGame; @end #import "GameController.h" #define GameStateRunning 1 #define GameStatePause 2 #define BallSpeedX 0.2 #define BallSpeedY 0.3 #define CompMoveSpeed 15 #define ScoreToWin 5 @implementation GameController @synthesize leftPaddle, rightPaddle, ball; - (id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if(self) { gameState = GameStatePause; ballVelocity = CGPointMake(BallSpeedX, BallSpeedY); [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(gameLoop) userInfo:nil repeats:YES]; } return self; } - (void)gameLoop { if(gameState == GameStateRunning) { [ball setFrameOrigin:CGPointMake(ball.frame.origin.x + ballVelocity.x, ball.frame.origin.y + ballVelocity.y)]; if(ball.frame.origin.x + 15 > self.frame.size.width || ball.frame.origin.x < 0) { ballVelocity.x =- ballVelocity.x; } if(ball.frame.origin.y + 35 > self.frame.size.height || ball.frame.origin.y < 0) { ballVelocity.y =- ballVelocity.y; } } if(CGRectIntersectsRect(ball.frame, leftPaddle.frame)) { if(ball.frame.origin.x > leftPaddle.frame.origin.x) { ballVelocity.x =- ballVelocity.x; } } if(CGRectIntersectsRect(ball.frame, rightPaddle.frame)) { if(ball.frame.origin.x +15 > rightPaddle.frame.origin.x) { ballVelocity.x =- ballVelocity.x; } } if(ball.frame.origin.x <= self.frame.size.width / 2) { if(ball.frame.origin.y < leftPaddle.frame.origin.y + 75 && leftPaddle.frame.origin.y > 0) { [leftPaddle setFrameOrigin:CGPointMake(leftPaddle.frame.origin.x, leftPaddle.frame.origin.y - CompMoveSpeed)]; } if(ball.frame.origin.y > leftPaddle.frame.origin.y +75 && leftPaddle.frame.origin.y < 700 - leftPaddle.frame.size.height ) { [leftPaddle setFrameOrigin:CGPointMake(leftPaddle.frame.origin.x, leftPaddle.frame.origin.y + CompMoveSpeed)]; } } if(ball.frame.origin.x <= 0) { player2Score++; [self reset:(player2Score >= ScoreToWin)]; } if(ball.frame.origin.x + 15 > self.frame.size.width) { player1Score++; [self reset:(player1Score >= ScoreToWin)]; } } - (void)reset:(BOOL)newGame { gameState = GameStatePause; [ball setFrameOrigin:CGPointMake((self.frame.size.width + 7.5) / 2, (self.frame.size.height + 7.5)/2)]; if(newGame) { if(player1Score > player2Score) { NSLog(@"Player 1 Wins!"); } else { NSLog(@"Player 2 Wins!"); } player1Score = 0; player2Score = 0; } else { NSLog(@"Press key to serve"); } NSLog(@"Player 1: %d",player1Score); NSLog(@"Player 2: %d",player2Score); } - (void)moveRightPaddleUp { if(rightPaddle.frame.origin.y < 700 - rightPaddle.frame.size.height) { [rightPaddle setFrameOrigin:CGPointMake(rightPaddle.frame.origin.x, rightPaddle.frame.origin.y + 20)]; } } - (void)moveRightPaddleDown { if(rightPaddle.frame.origin.y > 0) { [rightPaddle setFrameOrigin:CGPointMake(rightPaddle.frame.origin.x, rightPaddle.frame.origin.y - 20)]; } } - (BOOL)acceptsFirstResponder { return YES; } - (void)keyDown:(NSEvent *)theEvent { if ([theEvent modifierFlags] & NSNumericPadKeyMask) { NSString *theArrow = [theEvent charactersIgnoringModifiers]; unichar keyChar = 0; if ( [theArrow length] == 0 ) { return; // reject dead keys } if ( [theArrow length] == 1 ) { keyChar = [theArrow characterAtIndex:0]; if ( keyChar == NSLeftArrowFunctionKey ) { gameState = GameStateRunning; } if ( keyChar == NSRightArrowFunctionKey ) { } if ( keyChar == NSUpArrowFunctionKey ) { [self moveRightPaddleUp]; } if ( keyChar == NSDownArrowFunctionKey ) { [self moveRightPaddleDown]; } [super keyDown:theEvent]; } } else { [super keyDown:theEvent]; } } - (void)drawRect:(NSRect)dirtyRect { } - (void)dealloc { [ball release]; [rightPaddle release]; [leftPaddle release]; [super dealloc]; } @end

    Read the article

  • Custom Date Format with jax-rs in apache cxf?

    - by Oscar Chan
    Hi, I have been googling to figure out how I can customize the Date format when I use jax-rs on apache CXF. I looked at the codes, and it seems that it only support primitives, enum and a special hack that assume the type associated with @ForumParam has a constructor with a single string parameter. This force me to use String instead of Date if I want to use ForumParam. it is kind of ugly. Is there a better way to do it? @POST @Path("/xxx") public String addPackage(@FormParam("startDate") Date startDate) { ... } Thanks

    Read the article

  • My cocoa app won't capture key events

    - by Oscar
    Hi, i usually develop for iPhone. But now trying to make a pong game in Cocoa desktop application. Working out pretty well, but i can't find a way to capture key events. Here's my code: #import "PongAppDelegate.h" #define GameStateRunning 1 #define GameStatePause 2 #define BallSpeedX 10 #define BallSpeedY 15 @implementation PongAppDelegate @synthesize window, leftPaddle, rightPaddle, ball; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { gameState = GameStateRunning; ballVelocity = CGPointMake(BallSpeedX, BallSpeedY); [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(gameLoop) userInfo:nil repeats:YES]; } - (void)gameLoop { if(gameState == GameStateRunning) { [ball setFrameOrigin:CGPointMake(ball.frame.origin.x + ballVelocity.x, ball.frame.origin.y + ballVelocity.y)]; if(ball.frame.origin.x + 15 > window.frame.size.width || ball.frame.origin.x < 0) { ballVelocity.x =- ballVelocity.x; } if(ball.frame.origin.y + 35 > window.frame.size.height || ball.frame.origin.y < 0) { ballVelocity.y =- ballVelocity.y; } } } - (void)keyDown:(NSEvent *)theEvent { NSLog(@"habba"); // Arrow keys are associated with the numeric keypad if ([theEvent modifierFlags] & NSNumericPadKeyMask) { [window interpretKeyEvents:[NSArray arrayWithObject:theEvent]]; } else { [window keyDown:theEvent]; } } - (void)dealloc { [ball release]; [rightPaddle release]; [leftPaddle release]; [super dealloc]; } @end

    Read the article

  • Cocoa Key event problem

    - by Oscar
    I'm trying to build my first cocoa application. done some iPhone developing before. I have a hard time understanding how to layout my project. i making a Pong game and my current design is to allocate an NSWindowController from my appDelegate. I then use custom view to act as paddles and ball. My problem is that i can't get the window controller to capture key events. Am i thinking wrong here? My idea is to have a controller class with all the logic, should i subclass another class for that?

    Read the article

  • Select the first row in a join of two tables in one statement

    - by Oscar Cabrero
    hi i need to select only the first row from a query that joins tables A and B, on table B exist multiple records with same name. there are not identifiers in any of the two tables. i cannt change the scheme either because i do not own the DB TABLE A NAME TABLE B NAME DATA1 DATA2 Select Distinct A.NAME,B.DATA1,B.DATA2 From A Inner Join B on A.NAME = B.NAME this gives me NAME DATA1 DATA2 sameName 1 2 sameName 1 3 otherName 5 7 otherName 8 9 but i need to retrieve only one row per name NAME DATA1 DATA2 sameName 1 2 otherName 5 7 i was able to do this by adding the result into a temp table with a identity column and the select the Min Id per name. the problem here is that i require to do this in one single statement. this is a DB2 database thanks

    Read the article

  • 'int' object is not callable

    - by Oscar Reyes
    I'm trying to define a simply Fraction class And I'm getting this error: python fraction.py Traceback (most recent call last): File "fraction.py", line 20, in <module> f.numerator(2) TypeError: 'int' object is not callable The code follows: class Fraction(object): def __init__( self, n=0, d=0 ): self.numerator = n self.denominator = d def get_numerator(self): return self.numerator def get_denominator(self): return self.denominator def numerator(self, n): self.numerator = n def denominator( self, d ): self.denominator = d def prints( self ): print "%d/%d" %(self.numerator, self.denominator) if __name__ == "__main__": f = Fraction() f.numerator(2) f.denominator(5) f.prints() I thought it was because I had numerator(self) and numerator(self, n) but now I know Python doesn't have method overloading ( function overloading ) so I renamed to get_numerator but that's not the problems. What could it be?

    Read the article

  • Why am I having this InstantiationException in Java when accessing final local variables?

    - by Oscar Reyes
    I was playing with some code to make a "closure like" construct ( not working btw ) Everything looked fine but when I tried to access a final local variable in the code, the exception InstantiationException is thrown. If I remove the access to the local variable either by removing it altogether or by making it class attribute instead, no exception happens. The doc says: InstantiationException Thrown when an application tries to create an instance of a class using the newInstance method in class Class, but the specified class object cannot be instantiated. The instantiation can fail for a variety of reasons including but not limited to: - the class object represents an abstract class, an interface, an array class, a primitive type, or void - the class has no nullary constructor What other reason could have caused this problem? Here's the code. comment/uncomment the class attribute / local variable to see the effect (lines:5 and 10 ). import javax.swing.*; import java.awt.event.*; import java.awt.*; class InstantiationExceptionDemo { //static JTextField field = new JTextField();// works if uncommented public static void main( String [] args ) { JFrame frame = new JFrame(); JButton button = new JButton("Click"); final JTextField field = new JTextField();// fails if uncommented button.addActionListener( new _(){{ System.out.println("click " + field.getText()); }}); frame.add( field ); frame.add( button, BorderLayout.SOUTH ); frame.pack();frame.setVisible( true ); } } class _ implements ActionListener { public void actionPerformed( ActionEvent e ){ try { this.getClass().newInstance(); } catch( InstantiationException ie ){ throw new RuntimeException( ie ); } catch( IllegalAccessException ie ){ throw new RuntimeException( ie ); } } } Is this a bug in Java? edit Oh, I forgot, the stacktrace ( when thrown ) is: Caused by: java.lang.InstantiationException: InstantiationExceptionDemo$1 at java.lang.Class.newInstance0(Class.java:340) at java.lang.Class.newInstance(Class.java:308) at _.actionPerformed(InstantiationExceptionDemo.java:25)

    Read the article

  • iPhone - dismiss multiple ViewControllers

    - by Oscar Peli
    Hi there, I have a long View Controllers hierarchy; in the first View Controller I use this code: SecondViewController *svc = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; [self presentModalViewController:svc animated:YES]; [svc release]; In the second View Controller I use this code: ThirdViewController *tvc = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil]; [self presentModalViewController:tvc animated:YES]; [tvc release]; and so on. So there is a moment when I have many View Controllers and I need to come back to the first View Controller. If I come back one step at once, I use in every View Controller this code: [self dismissModalViewControllerAnimated:YES]; If I want to go back directly from the, say, sixth View Controller to the first one, what I have to do to dismiss all the Controllers at once? Thanks

    Read the article

  • Implement a simple class in your favorite language.

    - by Oscar Reyes
    I'm doing this to learn syntax of different programming languages. So, how would you defined the following class along with with it's operations in your favorite programming language? Image generated by http://yuml.me/ And a main method or equivalent to invoke it: For instance, for Java it would be: ... public static void main( String [] args ) { Fraction f = new Fraction(); f.numerator( 2 ); f.denominator( 5 ); f.print(); } ....

    Read the article

  • Can someone exaplain me implicit parameters in Scala?

    - by Oscar Reyes
    And more specifically how does the BigInt works for convert int to BigInt? In the source code it reads: ... implicit def int2bigInt(i: Int): BigInt = apply(i) ... How is this code invoked? I can understand how this other sample: "Date literals" works. In. val christmas = 24 Dec 2010 Defined by: implicit def dateLiterals(date: Int) = new { import java.util.Date def Dec(year: Int) = new Date(year, 11, date) } When int get's passed the message Dec with an int as parameter, the system looks for another method that can handle the request, in this case Dec(year:Int) Q1. Am I right in my understanding of Date literals? Q2. How does it apply to BigInt? Thanks

    Read the article

  • Android - overlay small check icon over specific image in gridview or change border

    - by oscar
    I've just asked a question about an hour ago, while waiting for replies, I've thought maybe I can achieve what I want differently. I was thinking of changing the image but it would be better if I could perhaps overlay something over the top of complete levels in the gridview i.e a small tick icon At the moment, when a level has been completed I am storing that with sharedpreferences So I have a gridView layout to display images that represent levels. Let's just say for this example I have 20 levels. When one level is complete is it possible to overlay the tick icon or somehow highlight the level image. Maybe change the border of the image?? Here are the image arrays I use int[] imageIDs = { R.drawable.one, R.drawable.two, R.drawable.three, R.drawable.four, R.drawable.five, R.drawable.six etc....... and then I have my code to set the images in gridView. Obviously there is more code in between. public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView; if (convertView == null) { imageView = new ImageView(context); imageView.setLayoutParams(new GridView.LayoutParams(140, 140)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(5, 5, 5, 5); } else { imageView = (ImageView) convertView; } imageView.setImageResource(imageIDs[position]); return imageView; would it be possible to do any of the above, even the border method would be fine. Thanks for any help

    Read the article

  • Call phpexcel from joomla

    - by Oscar Calderon
    i have a problem about phpexcel and joomla. I'm developing some filter form to load excel reports, so i used phpexcel library to do this. Right now i have only a report, it works fine, but after that i upload inside joomla using PHP pages component that allows me to put php files inside joomla and call it. When i put them, i change a little bit the form that calls the php that generates the excel report, i call the php using a link like this: h**p://www.whiblix.com/index.php?option=com_php&Itemid=24 That is, calling it from Joomla, not directly the php. If i wanna call the php directly i could use this path: h**p://www.whiblix.com/components/com_php/files/repImportaciones.php What's the problem? The problem is, when i call the php that generates the excel through joomla, the excel that is downloaded is corrupt and only shows symbols in one cell when i open it. But if i call the php directly the report is generated fine. I could call the php directly, the problem is that if i call it directly i can't use this line of code: defined( '_JEXEC' ) or die( 'Restricted access' ); That is used to deny the direct access to php from call it directly, because it doesn' work because the security. Where's the problem? This is the code of php that generates the report (ommiting the code where generates the rows and cells): <?php //defined( '_JEXEC' ) or die( 'Restricted access' ); /** Error reporting */ error_reporting(E_ALL); date_default_timezone_set('Europe/London'); require_once 'Classes/PHPExcel.php'; // Create new PHPExcel object $objPHPExcel = new PHPExcel(); // Set properties $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw") ->setTitle("Office 2007 XLSX Test Document") ->setSubject("Office 2007 XLSX Test Document") ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") ->setKeywords("office 2007 openxml php") ->setCategory("Test result file"); // Rename sheet $objPHPExcel->getActiveSheet()->setTitle('Reporte de Importaciones'); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $objPHPExcel->setActiveSheetIndex(0); // Redirect output to a client’s web browser (Excel5) header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="repPrueba.xls"'); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); exit;

    Read the article

  • Converting old Mailer to Rails 3 (multipart/mixed)

    - by Oscar Del Ben
    I'm having some difficulties converting this old mailer api to rails 3: content_type "multipart/mixed" part :content_type => "multipart/alternative" do |alt| alt.part "text/plain" do |p| p.body = render_message("summary_report.text.plain.erb", :message = message.gsub(/<.br./,"\n"), :campaign=campaign, :aggregate=aggregate, :promo_messages=campaign.participating_promo_msgs) end alt.part "text/html" do |p| p.body = render_message("summary_report.text.html.erb", :message = message, :campaign=campaign, :aggregate=aggregate,:promo_messages=campaign.participating_promo_msgs) end end if bounce_path attachment :content_type => "text/csv", :body=> File.read(bounce_path), :filename => "rmo_bounced_emails.csv" end attachment :content_type => "application/pdf", :body => File.read(report_path), :filename=>"rmo_report.pdf" In particular I don't understand how to differentiate the different multipart options. Any idea?

    Read the article

  • How to update Xcode to install "UNIX Development Support"

    - by Oscar Reyes
    I installed Xcode a long time ago. Apparently I didn't check back then the "UNIX Developemtn Support" checkbox. Now I want to have them bu when I click on the installation this is what appears: The UNIX Development Support check box is disabled Q. ¿How can I install the UNIX Development Support? Is there a way to run some script that creates all the needed links from /Developer/ to /usr/bin ? Thanks in advance.

    Read the article

  • Sort months ( with strings ) algorithm

    - by Oscar Reyes
    I have this months array: ["January", "March", "December" , "October" ] And I want to have it sorted like this: ["January", "March", "October", "December" ] I'm currently thinking in a "if/else" horrible cascade but I wonder if there is some other way to do this. The bad part is that I need to do this only with "string" ( that is, without using Date object or anything like that ) What would be a good approach?

    Read the article

  • Is it redundant to say: "JavaScript + AJAX"?

    - by Oscar Reyes
    In a recent discussion I had, somebody told me that is incorrect to say that because Ajax is Javascript already. The contenxt: "How do I blablablabal in a webpage so it doesn't have to do a page refresh" My answer: "Use JavaScript + Ajax" EDIT Ok, it is, so... how should I say it? "Use AJAX"? or "Use Javascript"?

    Read the article

  • How should I organize my C# classes? [closed]

    - by oscar.fimbres
    I'm creating an email generator system. I'm creating some clases and I'm trying to make things right. By the time, I have created 5 classes. Look at the class diagram: I'm going to explain you each one. Person. It's not a big deal. Just have two constructors: Person(fname, lname1, lname2) and Person(token, fname, lname1, lname2). Note that email property stays without value. StringGenerator. This is a static class and it has only a public function: Generate. The function receives a Person class and it will return a list of patterns for the email. MySql. It contains all the necessary to connect to a database. Database. This class inherits from MySql class. It has particular functions for the database. This gets all the registries from a table (function GetPeople) and return a List. Each person from the list contains all data except Email. Also it can add records (List but this must contains an available email). An available email is when an email doesn't have another person. For that reason, I have a method named ExistsEmail. Container. This is the class which is causing me some problems. It's like a temporary container. It supposed to have a people list from GetPeople (in Database class) and for each person it adds, it must generate a list of possible names (StringGenerator.Generate), then it selects one of the list and it must check out if exists in the database or in the same container. As I told above this is temporal, it may none of the possible emails is available. So the user can modify or enter a custom email available and update the list in this container. When all the email's people are available, it sends a list to add in the database, It must have a Flush method, to insert all the people in the database. I'm trying to design correct class. I need a little help to improve or edite the classes, because I want to separate the logic and visual, and learn of you. I hope you've been able to understand me. Any question or doubt, please let me know. Anyway, I attached the solution here to better understand it: http://www.megaupload.com/?d=D94FH8GZ

    Read the article

  • Linq to SQL duplicating entry when referencing FK

    - by Oscar
    Hi! I am still facing some problems when using LINQ-to-SQL. I am also looking for answers by myself, but this problem is so akward that I am having problems to find the right keywords to look for it. I have this code here: public CustomTask SaveTask(string token, CustomTask task) { TrackingDataContext dataConext = new TrackingDataContext(); //Check the token for security if (SessionTokenBase.Instance.ExistsToken(Convert.ToInt32(token)) == null) return null; //Populates the Task - the "real" Linq to SQL object Task t = new Task(); t.Title = task.Title; t.Description = task.Description; //****The next 4 lines are important**** if (task.Severity != null) t.Severity = task.Severity; else t.SeverityID = task.SeverityID; t.StateID = task.StateID; if (task.TeamMember != null) t.TeamMember = task.TeamMember; else t.ReporterID = task.ReporterID; if (task.ReporterTeam != null) t.Team = task.ReporterTeam; else t.ReporterTeamID = task.ReporterTeamID; //Saves/Updates the task dataConext.Tasks.InsertOnSubmit(t); dataConext.SubmitChanges(); task.ID = t.ID; return task; } The problem is that I am sending the ID of the severity, and then, when I get this situation: DB State before calling the method: ID Name 1 high 2 medium 3 low Call the method selecting "medium" as severity DB State after calling the method: ID Name 1 high 2 medium 3 low 4 medium The point is: -It identified that the ID was related to the Medium entry (and for this reason it could populate the "Name" Column correctly), but if duplicated this entry. The problem is: Why?!! Some explanation about the code: CustomTask is almost the same as Task, but I was having problems regarding serialization as can be seen here I don't want to send the Severity property populated because I want my message to be as small as possible. Could anyone clear to my, why it recognize the entry, but creates a new entry in the DB?

    Read the article

  • Engineering techniques to diminish MVVM Driven Development time?

    - by Oscar Cabrero
    Hi Currently we just start releasing modules for a big project in MVVM but seems like the deliverables are starting to encounter a slowness with this model, such things as the learning curve effort and the fact that mvvm do requires a bit more code than other patterns, What Programming and software engineering techniques do you employ or thing could help us reduce the effort and speed up development? things like code generation with T4 templates, ligth MVVM frameworks, use Expression Blend, hire a designer to hanle UX. Thanks for any advice you could provide.

    Read the article

< Previous Page | 2 3 4 5 6 7 8  | Next Page >