Search Results

Search found 951 results on 39 pages for 'surface'.

Page 6/39 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • How do I multiply pixels on an SDL Surface?

    - by NoobScratcher
    Okay so I'm able to put blank pixels into a surface and also draw gradient pixels rectangles,etc But I don't know how to multiply the pixels on a surface so I was hoping someone could provide me information on this topic. I was thinking you could get the members pixel and then * it by 2 but that didn't provide results I wanted so I'm now thinking that you have to actually get to the position in bytes in one location to the left and one location to the right and then store it in memory and then * that by 2 am I correct or what? If so what is it that allows me to do that and how do I do that?

    Read the article

  • Microsoft fait un pas de plus vers la démocratisation de Surface, en dévoilant une nouvelle mouture de sa table tactile

    Microsoft fait un pas de plus vers la démocratisation de Surface, en dévoilant une nouvelle mouture de sa table tactile Mise à jour du 06.01.2011 par Katleen Souvenez-vous de la Surface, cette table basse tactile développée par Microsoft que nous vous présentions en novembre 2009. L'objet était déjà très intéressant, mais connaissait quelques lenteurs et était plutôt massif (ceux qui l'ont déjà déplacé s'en souviennent assurément). En plus de cela, le joujou était extrêmement coûteux, de quoi vous faire dire que son acquisition, ça ne sera même pas dans dix ou vingt ans (sans les intérêts). Microsoft nourrissait déjà à l'époque l'espoir de voir un jour sa technologie plus accessible. Et la firme semble emprunter ce chemin.

    Read the article

  • Surface sous Windows RT sera supportée jusqu'en avril 2017, la tablette de Microsoft recevra des mises à jour pendant plus de 4 ans

    Surface sous Windows RT sera supportée jusqu'en avril 2017 la tablette de Microsoft recevra des mises à jour pendant plus de 4 ans Surface sous Windows RT bénéficiera d'un support de 4 ans et demi. Microsoft a procédé à une mise à jour de sa politique de support en intégrant une nouvelle section pour sa tablette fonctionnant avec la version ARM de Windows. Les possesseurs du dispositif pourront recevoir des mises à jour logicielles, des correctifs de sécurité, ainsi que des mises à jour du firmware (micrologiciel intégré dans le hardware) jusqu'au 24 avril 2017. Contrairement aux versions traditionnelles de Windows qui bénéficient d'un support principal de 5 ans, Mi...

    Read the article

  • Xbox Surface : bientôt une tablette 7 pouces dédiée au jeu ? Microsoft plancherait sur le sujet

    Xbox Surface : bientôt une tablette 7 pouces dédiée au jeu ? Microsoft plancherait sur le sujet Après Apple avec l'iPad Mini, ce serait au tour de Microsoft de se lancer dans la conception d'une tablette de petite taille (7 pouces). À la différence d'autres dispositifs du même type, la tablette de Microsoft sera spécialement optimisée pour le jeu. Selon un article du magazine The Verge des sources proches de Microsoft, le développement du projet aurait même déjà bien évolué. La tablette xBox Surface reposera sur une architecture ARM spécifique avec une bande passante mémoire importante, afin de pouvoir répondre aux besoins d'un GPU plus puissant que celui disponible ...

    Read the article

  • Sevensteps and I are joining forces

    - by Dennis Vroegop
    As of today, I will be partnering with Sevensteps when it comes to developing great Surface, Windows Phone 7 and Windows 7 Touch applications. Below you’ll find the press release we sent out today. I am looking forward to this partnership and expect great things coming from us both in the future!   Dennis Vroegop, Microsoft MVP, joins Sevensteps partner network 1 March 2011, Seattle / Amersfoort Today Dennis Vroegop and Bart Roozendaal, both Microsoft Most Valuable Professional for Microsoft Surface, announce the joining of Dennis Vroegop to the Sevensteps partner network. Dennis and Bart already worked together very closely through the Microsoft MVP connection, but decided to combined their efforts to make the new Microsoft Surface and our solutions for it, a success. Dennis will join the other Sevensteps partners in creating state of the art solutions for Microsoft Surface, Windows Phone 7 and Windows 7 Touch. Dennis brings a vast amount of knowledge about these technologies, as well as his network in the Dutch developer community. With Dennis joining the Sevensteps partner network we bring unique expertise, power and insight in the platforms, that no other company worldwide can offer. This step brings our goal of Sevensteps being the knowledge hub for Microsoft Surface of choice a whole lot closer. About Dennis Vroegop Dennis is a Microsoft MVP for Microsoft Surface and chairman of the Dutch dotNed user group. He has a long history promoting Microsoft Surface in the developer community. Dennis is a regular speaker at local and international conferences and a frequent writer of articles, including but not limited to Microsoft Surface. Dennis has a bachelor’s degree in computer sciences and has spent all of his professional life writing software for the Microsoft platform. About Sevensteps For more information about Sevensteps and Bart Roozendaal please point to http://www.sevensteps.com Tags: surface,wp7,windows touch

    Read the article

  • WPF: Binding to commands in code behind

    - by sofri
    Hi, I have an WPF Microsoft Surface Applikation and I'm using MVVM-Pattern. I have some buttons that are created in code behind. And I would like to bind commands to them but I only know how that works in the XAML like this: <Custom:SurfaceButton Command="{Binding SaveReservationCommandBinding, Mode=OneWay}"/> But I cannot do it like this because my buttons do not exist in the XAML, only in the code behind. So how would a command binding like that works in code behind?

    Read the article

  • Preserve the state of the start screen

    - by axrwkr
    What would I need to do in order to cause the start screen to stay the way it was the last time I saw it when I go back to it? I've noticed that every time I leave the start screen it resets back to the beginning, this means that I need to scroll back to where I was to get the same view. I don't want to change the order of the applications on the start screen to accommodate this, I would much prefer it if I could find a way to make the start screen stay the way it was so I can move on from there and also if there was a way to jump to the beginning or the end of the list that would be great. I imagine I can just use the search feature to find a specific program, but that's just an extra step, almost as bad as having to scroll.

    Read the article

  • How does one switch tracks in Windows 8.1's XBox Music app?

    - by XBone
    XBox Music Now Playing In the XBox Music app (both app and Windows completely updated) I tried playing a folder full of MP3s from a USB HDD. In the screenshot above the track Sometimes is currently playing (indicated by the small green spectrum analyzer icon to the left). Now suppose I want to start playing the sixth track So Hard, how do I do it without pressing the Next Track button five times? Double-clicking (using touch) doesn't work and selecting the track by swiping left or right doesn't show any Play Now option in the bar that pops up from the bottom. Cannot believe the default music player app is so bad! :o

    Read the article

  • LibraryContainer in a ScatterViewItem: resizing and background rectangle...

    - by Rob Fleming
    Simple one: Want to add a LibraryContainer to a Surface ScatterView. Know I have to add the container inside a ScatterViewItem to get the rotate/move features.. but the SVI adds a rectangle box around the control, and it does not size correctly. Think I'm missing something simple but can't figure it... My current XAML is as follows: Background="{StaticResource WindowBackground}" AllowDrop="True" . . . Any thoughts are appreciated... I've been looking at the how-to samples but the library controls that are shown are static item. (ie they are not movable)... Rob

    Read the article

  • How do I draw a texture-mapped triangle in MATLAB?

    - by Petter
    I have a triangle in (u,v) coordinates in an image. I would like to draw this triangle at 3D coordinates (X,Y,Z) texture-mapped with the triangle in the image. Here, u,v,X,Y,Z are all vectors with three elements representing the three corners of the triangle. I have a very ugly, slow and unsatisfactory solution in which I (1) extract a rectangular part of the image, (2) transform it to 3D space with the transformation defined by the three points, (3) draw it with surface, and (4) finally masking out everything that is not part of the triangle with AlphaData. Surely there must be an easier way of doing this?

    Read the article

  • How can I use a config-file in Expression Blend 4?

    - by sofri
    Hi, while trying to use the "InfoStrat"-Bing-Maps-Control in Expression Blend 4 for my Surface Application, I get the error message: "Mixed mode assembly is built against version v2.0.50527 of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information" I already found out that I need to write this configfile: <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup> </configuration> But Expression Blend doesn't seem to recognize that it is there. So how can I solve this problem?

    Read the article

  • Making the shadow from a ScatterViewItem a different shape

    - by Vargen
    I am developing a program for Surface using Expression Blend and Visual Studio. I have a custom user control with an ellipse and a label in a grid. This will need to be placed in a scatterViewItem. My problem is that the scatterviewitem will cast a rectangle shaped shadow under the ellipse shaped content. I can disable the shadow completely, but is there any way to make the shadow inherit the shape from its parent? Or can i set the shape of the scatterviewItem itself in any way?

    Read the article

  • WPF: Reset the positions of scatterviewitems?

    - by sofri
    Hi, I have a scatterview with some items in it which I place with Orientation und Center. Now I want to have the possibility to reset the positions of the scatterviewitems after scaling, rotating and moving them, while the program is running. At the moment I do it this way: private void Reset_ContactTapGesture(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) { item1.Center = new Point(150,150); item1.Orientation = 15; item1.Width = 100; item1.Height = 150; } Is there a better way to do it?

    Read the article

  • Adding a textblock to a custom wpf control (piepiece control from codeplex)

    - by bomortensen
    Hi Stackoverflow! I'm currently building a Surface application where the main navigation is a circular menu. For each menu item I'm using a custom control that I found on codeproject.com: http://www.codeproject.com/KB/WPF/PieChartDataBinding.aspx (PiePiece control) The number of submenu items (which is also piepiece controls) comes from a database and thus dynamically loaded. What I can't figure out is how I add a textblock to this custom control to display the submenu item text. It needs to follow the PiePiece's RotationAngle property to line up correctly. Anyone got a hot-fix for this? I was thinking about adding another dependencyproperty to the piepiece custom control, but that way I can't set the font-family, size etc (can I?) Any input on this is greatly appreciated! Thanks!

    Read the article

  • wrong font in a RichTextBox importing from .rtf

    - by giacomellow
    Hi all, I'm developing a microsoft surface application using expression blend+vs 2008. I have a RichTextBox that loads formatted text from an .rtf file. The text is formatted with uppecases, color, and specific font (helvetica-neue). When i load the text, it is displayed in the control with matching format (color and uppecase) but NOT matching font. it seems to use the standard Blend font (Thaoma). the text is loaded with this function: public static RichTextBox SetRTFText(string text, RichTextBox richTextBox) { MemoryStream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(text)); TextRange documentTextRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd); documentTextRange.Load(stream, DataFormats.Rtf ); return richTextBox; } thank you all!

    Read the article

  • Speaking at Mix11

    - by Dennis Vroegop
    In April Microsoft will hold the next MIX event. MIX was usually targeted at web designers and developers but has grown over the years to be more a general conference focused on the web and devices. In other words: everything the normal consumer might encounter. It’s not your typical developers conference, although you’ll find many developers there as well. But next to the developers you’ll probably run into designers and user experience specialists as well. This year I am proud to say that I will be one of the people presenting there. Together with all the Surface MVP’s in the world (sounds impressive, but there are only 7 of us) we’ll host a panel discussion on all things Surface, NUI and everything else that matches those subjects. Here’s what the abstract says: The Natural User Interface (NUI) is a hot topic that generates a lot of excitement, but there are only a handful of companies doing real innovation with NUIs and most of the practical experience in the NUI style of design and development is limited to a small number of experts. The Microsoft Surface MVPs are a subset of these experts that have extensive real-world experience with Microsoft Surface and other NUI devices. This session is a panel featuring the Microsoft Surface MVPs and an unfiltered discussion with each other and the audience about the state of the art in NUI design and development. We will share our experiences and ideas, discuss what we think NUI will look like in the near future, and back up our statements with cutting-edge demonstrations prepared by the panelists involving combinations of Microsoft Surface 2.0, Kinect, and Windows Phone 7. We, as Surface MVPs think we are more than just Surface oriented. We like to think we are more NUI MVP’s. But since that’s not a technology with Microsoft you can’t actually become a NUI MVP so Surface is the one that comes the closest. We are currently working on the details of our session but believe me: it will blow you away. Several people we talked to have said this could potentially be the best session of Mix. Quite a challenge, but we’re up for it! Of course I won’t be telling you exactly what we’re going to do in Las Vegas but rest assured that when you visit our session you’ll leave with a lot of new ideas and hopefully be inspired to bring into practice what you’ve seen. Even if the technology we’ll show you isn’t readily available yet. So, if you are in Las Vegas between April 12th and 14th, please join Joshua Blake, Neil Roodyn, Rick Barraza, Bart Roozendaal, Josh Santangelo, Nicolas Calvi and myself for some NUI fun! See you in Vegas! Tags van Technorati: mix11,las vegas,surface,nui,kinecct

    Read the article

  • Is there a way to show a 3-D surface plot in the browser?

    - by Phage
    I've got a bunch of data for 3-D surface plots. I want to build a quick web interface to let me browse through that data. Are there any (free) packages out there that can easily show surface plots? I found this question but the suggested libraries did not support surface plots. If it requires a plugin like flash / java that is fine. This is for prototyping so a quick 'n dirty solution is preferred. Right now, the only option I have come up with is to use gnuplot to serve up static images. It would be awesome if there was some way to provide an interactive 3-D surface plot in the browser.

    Read the article

  • Les nouvelles pubs pour Windows 8 et un crash test de la tablette Surface veulent marquer une rupture dans la communication de Microsoft

    Les nouvelles pubs pour Windows 8 Et un crash test de la tablette Surface Windows 8 arrive après-demain. Et avec lui toute une batterie de nouvelles publicités. Si l'OS marque une rupture avec ses prédécesseurs, ces vidéos sont également censées faire entrer Microsoft dans une nouvelle ère de communication. « L'idée est d'être plus centré sur l'expérience produit ? montrer plus et parler moins ? en utilisant les registres émotionnels et culturels » explique Brandon LeBlanc, de l'équipe Windows 8, « la musique est donc au coeur de cette campagne ». Notamment avec des groupes en devenir comme Best Coast (USA), Labrinth (UK), Lenka (Chine) et Hogarth (Brésil) et ...

    Read the article

  • Displair : l'affichage 3D multi-touch devient une réalité commerciale, 1500 points de contact sur une surface allant jusqu'à 142 pouces

    Displair : l'affichage multi-touch en 3D en phase de devenir une réalité commerciale 1500 points de contact sur une surface allant jusqu'à 142 pouces Interagir avec un affichage volumétrique en 3D à la Minority Report devient-il une réalité fiable et commerciale ? Une société russe « Displair » dévoile en tout cas un système d'affichage qui s'en approche grandement. Displair utilise des projections laser sur une couche de brouillard froid pour reproduire des objets 3D dans le vide. Ce genre d'affichage holographique a fait ses balbutiements il y a bientôt une décennie et le produit n'aurait pas été aussi impressionnant sans une détection avancée du mouvement....

    Read the article

  • Help getting frame rate (fps) up in Python + Pygame

    - by Jordan Magnuson
    I am working on a little card-swapping world-travel game that I sort of envision as a cross between Bejeweled and the 10 Days geography board games. So far the coding has been going okay, but the frame rate is pretty bad... currently I'm getting low 20's on my Core 2 Duo. This is a problem since I'm creating the game for Intel's March developer competition, which is squarely aimed at netbooks packing underpowered Atom processors. Here's a screen from the game: ![www.necessarygames.com/my_games/betraveled/betraveled-fps.png][1] I am very new to Python and Pygame (this is the first thing I've used them for), and am sadly lacking in formal CS training... which is to say that I think there are probably A LOT of bad practices going on in my code, and A LOT that could be optimized. If some of you older Python hands wouldn't mind taking a look at my code and seeing if you can't find any obvious areas for optimization, I would be extremely grateful. You can download the full source code here: http://www.necessarygames.com/my_games/betraveled/betraveled_src0328.zip Compiled exe here: www.necessarygames.com/my_games/betraveled/betraveled_src0328.zip One thing I am concerned about is my event manager, which I feel may have some performance wholes in it, and another thing is my rendering... I'm pretty much just blitting everything to the screen all the time (see the render routines in my game_components.py below); I recently found out that you should only update the areas of the screen that have changed, but I'm still foggy on how that accomplished exactly... could this be a huge performance issue? Any thoughts are much appreciated! As usual, I'm happy to "tip" you for your time and energy via PayPal. Jordan Here are some bits of the source: Main.py #Remote imports import pygame from pygame.locals import * #Local imports import config import rooms from event_manager import * from events import * class RoomController(object): """Controls which room is currently active (eg Title Screen)""" def __init__(self, screen, ev_manager): self.room = None self.screen = screen self.ev_manager = ev_manager self.ev_manager.register_listener(self) self.room = self.set_room(config.room) def set_room(self, room_const): #Unregister old room from ev_manager if self.room: self.room.ev_manager.unregister_listener(self.room) self.room = None #Set new room based on const if room_const == config.TITLE_SCREEN: return rooms.TitleScreen(self.screen, self.ev_manager) elif room_const == config.GAME_MODE_ROOM: return rooms.GameModeRoom(self.screen, self.ev_manager) elif room_const == config.GAME_ROOM: return rooms.GameRoom(self.screen, self.ev_manager) elif room_const == config.HIGH_SCORES_ROOM: return rooms.HighScoresRoom(self.screen, self.ev_manager) def notify(self, event): if isinstance(event, ChangeRoomRequest): if event.game_mode: config.game_mode = event.game_mode self.room = self.set_room(event.new_room) def render(self, surface): self.room.render(surface) #Run game def main(): pygame.init() screen = pygame.display.set_mode(config.screen_size) ev_manager = EventManager() spinner = CPUSpinnerController(ev_manager) room_controller = RoomController(screen, ev_manager) pygame_event_controller = PyGameEventController(ev_manager) spinner.run() # this runs the main function if this script is called to run. # If it is imported as a module, we don't run the main function. if __name__ == "__main__": main() event_manager.py #Remote imports import pygame from pygame.locals import * #Local imports import config from events import * def debug( msg ): print "Debug Message: " + str(msg) class EventManager: #This object is responsible for coordinating most communication #between the Model, View, and Controller. def __init__(self): from weakref import WeakKeyDictionary self.listeners = WeakKeyDictionary() self.eventQueue= [] self.gui_app = None #---------------------------------------------------------------------- def register_listener(self, listener): self.listeners[listener] = 1 #---------------------------------------------------------------------- def unregister_listener(self, listener): if listener in self.listeners: del self.listeners[listener] #---------------------------------------------------------------------- def post(self, event): if isinstance(event, MouseButtonLeftEvent): debug(event.name) #NOTE: copying the list like this before iterating over it, EVERY tick, is highly inefficient, #but currently has to be done because of how new listeners are added to the queue while it is running #(eg when popping cards from a deck). Should be changed. See: http://dr0id.homepage.bluewin.ch/pygame_tutorial08.html #and search for "Watch the iteration" for listener in list(self.listeners): #NOTE: If the weakref has died, it will be #automatically removed, so we don't have #to worry about it. listener.notify(event) #------------------------------------------------------------------------------ class PyGameEventController: """...""" def __init__(self, ev_manager): self.ev_manager = ev_manager self.ev_manager.register_listener(self) self.input_freeze = False #---------------------------------------------------------------------- def notify(self, incoming_event): if isinstance(incoming_event, UserInputFreeze): self.input_freeze = True elif isinstance(incoming_event, UserInputUnFreeze): self.input_freeze = False elif isinstance(incoming_event, TickEvent): #Share some time with other processes, so we don't hog the cpu pygame.time.wait(5) #Handle Pygame Events for event in pygame.event.get(): #If this event manager has an associated PGU GUI app, notify it of the event if self.ev_manager.gui_app: self.ev_manager.gui_app.event(event) #Standard event handling for everything else ev = None if event.type == QUIT: ev = QuitEvent() elif event.type == pygame.MOUSEBUTTONDOWN and not self.input_freeze: if event.button == 1: #Button 1 pos = pygame.mouse.get_pos() ev = MouseButtonLeftEvent(pos) elif event.type == pygame.MOUSEMOTION: pos = pygame.mouse.get_pos() ev = MouseMoveEvent(pos) #Post event to event manager if ev: self.ev_manager.post(ev) #------------------------------------------------------------------------------ class CPUSpinnerController: def __init__(self, ev_manager): self.ev_manager = ev_manager self.ev_manager.register_listener(self) self.clock = pygame.time.Clock() self.cumu_time = 0 self.keep_going = True #---------------------------------------------------------------------- def run(self): if not self.keep_going: raise Exception('dead spinner') while self.keep_going: time_passed = self.clock.tick() fps = self.clock.get_fps() self.cumu_time += time_passed self.ev_manager.post(TickEvent(time_passed, fps)) if self.cumu_time >= 1000: self.cumu_time = 0 self.ev_manager.post(SecondEvent()) pygame.quit() #---------------------------------------------------------------------- def notify(self, event): if isinstance(event, QuitEvent): #this will stop the while loop from running self.keep_going = False rooms.py #Remote imports import pygame #Local imports import config import continents from game_components import * from my_gui import * from pgu import high class Room(object): def __init__(self, screen, ev_manager): self.screen = screen self.ev_manager = ev_manager self.ev_manager.register_listener(self) def notify(self, event): if isinstance(event, TickEvent): pygame.display.set_caption('FPS: ' + str(int(event.fps))) self.render(self.screen) pygame.display.update() def get_highs_table(self): fname = 'high_scores.txt' highs_table = None config.all_highs = high.Highs(fname) if config.game_mode == config.TIME_CHALLENGE: if config.difficulty == config.EASY: highs_table = config.all_highs['time_challenge_easy'] if config.difficulty == config.MED_DIF: highs_table = config.all_highs['time_challenge_med'] if config.difficulty == config.HARD: highs_table = config.all_highs['time_challenge_hard'] if config.difficulty == config.SUPER: highs_table = config.all_highs['time_challenge_super'] elif config.game_mode == config.PLAN_AHEAD: pass return highs_table class TitleScreen(Room): def __init__(self, screen, ev_manager): Room.__init__(self, screen, ev_manager) self.background = pygame.image.load('assets/images/interface/background.jpg').convert() #Initialize #--------------------------------------- self.gui_form = gui.Form() self.gui_app = gui.App(config.gui_theme) self.ev_manager.gui_app = self.gui_app c = gui.Container(align=0,valign=0) #Quit Button #--------------------------------------- b = StartGameButton(ev_manager=self.ev_manager) c.add(b, 0, 0) self.gui_app.init(c) def render(self, surface): surface.blit(self.background, (0, 0)) #GUI self.gui_app.paint(surface) class GameModeRoom(Room): def __init__(self, screen, ev_manager): Room.__init__(self, screen, ev_manager) self.background = pygame.image.load('assets/images/interface/background.jpg').convert() self.create_gui() #Create pgu gui elements def create_gui(self): #Setup #--------------------------------------- self.gui_form = gui.Form() self.gui_app = gui.App(config.gui_theme) self.ev_manager.gui_app = self.gui_app c = gui.Container(align=0,valign=-1) #Mode Relaxed Button #--------------------------------------- b = GameModeRelaxedButton(ev_manager=self.ev_manager) self.b = b print b.rect c.add(b, 0, 200) #Mode Time Challenge Button #--------------------------------------- b = TimeChallengeButton(ev_manager=self.ev_manager) self.b = b print b.rect c.add(b, 0, 250) #Mode Think Ahead Button #--------------------------------------- # b = PlanAheadButton(ev_manager=self.ev_manager) # self.b = b # print b.rect # c.add(b, 0, 300) #Initialize #--------------------------------------- self.gui_app.init(c) def render(self, surface): surface.blit(self.background, (0, 0)) #GUI self.gui_app.paint(surface) class GameRoom(Room): def __init__(self, screen, ev_manager): Room.__init__(self, screen, ev_manager) #Game mode #--------------------------------------- self.new_board_timer = None self.game_mode = config.game_mode config.current_highs = self.get_highs_table() self.highs_dialog = None self.game_over = False #Images #--------------------------------------- self.background = pygame.image.load('assets/images/interface/game screen2-1.jpg').convert() self.logo = pygame.image.load('assets/images/interface/logo_small.png').convert_alpha() self.game_over_text = pygame.image.load('assets/images/interface/text_game_over.png').convert_alpha() self.trip_complete_text = pygame.image.load('assets/images/interface/text_trip_complete.png').convert_alpha() self.zoom_game_over = None self.zoom_trip_complete = None self.fade_out = None #Text #--------------------------------------- self.font = pygame.font.Font(config.font_sans, config.interface_font_size) #Create game components #--------------------------------------- self.continent = self.set_continent(config.continent) self.board = Board(config.board_size, self.ev_manager) self.deck = Deck(self.ev_manager, self.continent) self.map = Map(self.continent) self.longest_trip = 0 #Set pos of game components #--------------------------------------- board_pos = (SCREEN_MARGIN[0], 109) self.board.set_pos(board_pos) map_pos = (config.screen_size[0] - self.map.size[0] - SCREEN_MARGIN[0], 57); self.map.set_pos(map_pos) #Trackers #--------------------------------------- self.game_clock = Chrono(self.ev_manager) self.swap_counter = 0 self.level = 0 #Create gui #--------------------------------------- self.create_gui() #Create initial board #--------------------------------------- self.new_board = self.deck.deal_new_board(self.board) self.ev_manager.post(NewBoardComplete(self.new_board)) def set_continent(self, continent_const): #Set continent based on const if continent_const == config.EUROPE: return continents.Europe() if continent_const == config.AFRICA: return continents.Africa() else: raise Exception('Continent constant not recognized') #Create pgu gui elements def create_gui(self): #Setup #--------------------------------------- self.gui_form = gui.Form() self.gui_app = gui.App(config.gui_theme) self.ev_manager.gui_app = self.gui_app c = gui.Container(align=-1,valign=-1) #Timer Progress bar #--------------------------------------- self.timer_bar = None self.time_increase = None self.minutes_left = None self.seconds_left = None self.timer_text = None if self.game_mode == config.TIME_CHALLENGE: self.time_increase = config.time_challenge_start_time self.timer_bar = gui.ProgressBar(config.time_challenge_start_time,0,config.max_time_bank,width=306) c.add(self.timer_bar, 172, 57) #Connections Progress bar #--------------------------------------- self.connections_bar = None self.connections_bar = gui.ProgressBar(0,0,config.longest_trip_needed,width=306) c.add(self.connections_bar, 172, 83) #Quit Button #--------------------------------------- b = QuitButton(ev_manager=self.ev_manager) c.add(b, 950, 20) #Generate Board Button #--------------------------------------- b = GenerateBoardButton(ev_manager=self.ev_manager, room=self) c.add(b, 500, 20) #Board Size? #--------------------------------------- bs = SetBoardSizeContainer(config.BOARD_LARGE, ev_manager=self.ev_manager, board=self.board) c.add(bs, 640, 20) #Fill Board? #--------------------------------------- t = FillBoardCheckbox(config.fill_board, ev_manager=self.ev_manager) c.add(t, 740, 20) #Darkness? #--------------------------------------- t = UseDarknessCheckbox(config.use_darkness, ev_manager=self.ev_manager) c.add(t, 840, 20) #Initialize #--------------------------------------- self.gui_app.init(c) def advance_level(self): self.level += 1 print 'Advancing to next level' print 'New level: ' + str(self.level) if self.timer_bar: print 'Time increase: ' + str(self.time_increase) self.timer_bar.value += self.time_increase self.time_increase = max(config.min_advance_time, int(self.time_increase * 0.9)) self.board = self.new_board self.new_board = None self.zoom_trip_complete = None self.game_clock.unpause() def notify(self, event): #Tick event if isinstance(event, TickEvent): pygame.display.set_caption('FPS: ' + str(int(event.fps))) self.render(self.screen) pygame.display.update() #Wait to deal new board when advancing levels if self.zoom_trip_complete and self.zoom_trip_complete.finished: self.zoom_trip_complete = None self.ev_manager.post(UnfreezeCards()) self.new_board = self.deck.deal_new_board(self.board) self.ev_manager.post(NewBoardComplete(self.new_board)) #New high score? if self.zoom_game_over and self.zoom_game_over.finished and not self.highs_dialog: if config.current_highs.check(self.level) != None: self.zoom_game_over.visible = False data = 'time:' + str(self.game_clock.time) + ',swaps:' + str(self.swap_counter) self.highs_dialog = HighScoreDialog(score=self.level, data=data, ev_manager=self.ev_manager) self.highs_dialog.open() elif not self.fade_out: self.fade_out = FadeOut(self.ev_manager, config.TITLE_SCREEN) #Second event elif isinstance(event, SecondEvent): if self.timer_bar: if not self.game_clock.paused: self.timer_bar.value -= 1 if self.timer_bar.value <= 0 and not self.game_over: self.ev_manager.post(GameOver()) self.minutes_left = self.timer_bar.value / 60 self.seconds_left = self.timer_bar.value % 60 if self.seconds_left < 10: leading_zero = '0' else: leading_zero = '' self.timer_text = ''.join(['Time Left: ', str(self.minutes_left), ':', leading_zero, str(self.seconds_left)]) #Game over elif isinstance(event, GameOver): self.game_over = True self.zoom_game_over = ZoomImage(self.ev_manager, self.game_over_text) #Trip complete event elif isinstance(event, TripComplete): print 'You did it!' self.game_clock.pause() self.zoom_trip_complete = ZoomImage(self.ev_manager, self.trip_complete_text) self.new_board_timer = Timer(self.ev_manager, 2) self.ev_manager.post(FreezeCards()) print 'Room posted newboardcomplete' #Board Refresh Complete elif isinstance(event, BoardRefreshComplete): if event.board == self.board: print 'Longest trip needed: ' + str(config.longest_trip_needed) print 'Your longest trip: ' + str(self.board.longest_trip) if self.board.longest_trip >= config.longest_trip_needed: self.ev_manager.post(TripComplete()) elif event.board == self.new_board: self.advance_level() self.connections_bar.value = self.board.longest_trip self.connection_text = ' '.join(['Connections:', str(self.board.longest_trip), '/', str(config.longest_trip_needed)]) #CardSwapComplete elif isinstance(event, CardSwapComplete): self.swap_counter += 1 elif isinstance(event, ConfigChangeBoardSize): config.board_size = event.new_size elif isinstance(event, ConfigChangeCardSize): config.card_size = event.new_size elif isinstance(event, ConfigChangeFillBoard): config.fill_board = event.new_value elif isinstance(event, ConfigChangeDarkness): config.use_darkness = event.new_value def render(self, surface): #Background surface.blit(self.background, (0, 0)) #Map self.map.render(surface) #Board self.board.render(surface) #Logo surface.blit(self.logo, (10,10)) #Text connection_text = self.font.render(self.connection_text, True, BLACK) surface.blit(connection_text, (25, 84)) if self.timer_text: timer_text = self.font.render(self.timer_text, True, BLACK) surface.blit(timer_text, (25, 64)) #GUI self.gui_app.paint(surface) if self.zoom_trip_complete: self.zoom_trip_complete.render(surface) if self.zoom_game_over: self.zoom_game_over.render(surface) if self.fade_out: self.fade_out.render(surface) class HighScoresRoom(Room): def __init__(self, screen, ev_manager): Room.__init__(self, screen, ev_manager) self.background = pygame.image.load('assets/images/interface/background.jpg').convert() #Initialize #--------------------------------------- self.gui_app = gui.App(config.gui_theme) self.ev_manager.gui_app = self.gui_app c = gui.Container(align=0,valign=0) #High Scores Table #--------------------------------------- hst = HighScoresTable() c.add(hst, 0, 0) self.gui_app.init(c) def render(self, surface): surface.blit(self.background, (0, 0)) #GUI self.gui_app.paint(surface) game_components.py #Remote imports import pygame from pygame.locals import * import random import operator from copy import copy from math import sqrt, floor #Local imports import config from events import * from matrix import Matrix from textrect import render_textrect, TextRectException from hyphen import hyphenator from textwrap2 import TextWrapper ############################## #CONSTANTS ############################## SCREEN_MARGIN = (10, 10) #Colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) RED = (255, 0, 0) YELLOW = (255, 200, 0) #Directions LEFT = -1 RIGHT = 1 UP = 2 DOWN = -2 #Cards CARD_MARGIN = (10, 10) CARD_PADDING = (2, 2) #Card types BLANK = 0 COUNTRY = 1 TRANSPORT = 2 #Transport types PLANE = 0 TRAIN = 1 CAR = 2 SHIP = 3 class Timer(object): def __init__(self, ev_manager, time_left): self.ev_manager = ev_manager self.ev_manager.register_listener(self) self.time_left = time_left self.paused = False def __repr__(self): return str(self.time_left) def pause(self): self.paused = True def unpause(self): self.paused = False def notify(self, event): #Pause Event if isinstance(event, Pause): self.pause() #Unpause Event elif isinstance(event, Unpause): self.unpause() #Second Event elif isinstance(event, SecondEvent): if not self.paused: self.time_left -= 1 class Chrono(object): def __init__(self, ev_manager, start_time=0): self.ev_manager = ev_manager self.ev_manager.register_listener(self) self.time = start_time self.paused = False def __repr__(self): return str(self.time_left) def pause(self): self.paused = True def unpause(self): self.paused = False def notify(self, event): #Pause Event if isinstance(event, Pause): self.pause() #Unpause Event elif isinstance(event, Unpause): self.unpause() #Second Event elif isinstance(event, SecondEvent): if not self.paused: self.time += 1 class Map(object): def __init__(self, continent): self.map_image = pygame.image.load(continent.map).convert_alpha() self.map_text = pygame.image.load(continent.map_text).convert_alpha() self.pos = (0, 0) self.set_color() self.map_image = pygame.transform.smoothscale(self.map_image, config.map_size) self.size = self.map_image.get_size() def set_pos(self, pos): self.pos = pos def set_color(self): image_pixel_array = pygame.PixelArray(self.map_image) image_pixel_array.replace(config.GRAY1, config.COLOR1) image_pixel_array.replace(config.GRAY2, config.COLOR2) image_pixel_array.replace(config.GRAY3, config.COLOR3) image_pixel_array.replace(config.GRAY4, config.COLOR4) image_pixel_array.replace(config.GRAY5, config.COLOR5)

    Read the article

  • How can I create a rectangular SDL surface filled with a particular color?

    - by user3689
    I'm learning SDL. I'd like to create rectangular surface filled with a flat color (not an image). Below is my code -- it compiles fine, but doesn't work. I'm passing the function these parameters: SDL_Surface* m_screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE ); SDL_FillRect( m_screen, &m_screen->clip_rect, SDL_MapRGB(m_screen->format,0xFF, 0xFF, 0xFF) ); ... Button button(m_screen,0,0,50,50,255,0,0) ... ... Button::Button(SDL_Surface* screen,int x,int y,int w,int h,int R, int G, int B) { SDL_Rect box; SDL_Surface * ButtonSurface; ButtonSurface = NULL ; Uint32 rmask, gmask, bmask, amask; #if SDL_BYTEORDER == SDL_BIG_ENDIAN rmask = 0xff000000; gmask = 0x00ff0000; bmask = 0x0000ff00; amask = 0x000000ff; #else rmask = 0x000000ff; gmask = 0x0000ff00; bmask = 0x00ff0000; amask = 0xff000000; #endif box.x = x; box.y = y; box.w = w; box.h = h; ButtonSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, box.w,box.h, 32, rmask, gmask, bmask, amask); if(ButtonSurface == NULL) { LOG_MSG("Button::Button Button failed"); } SDL_FillRect(screen,&box,SDL_MapRGB ( ButtonSurface->format, R, G, B )); //ut.ApplySurface(0,0,ButtonSurface,screen); SDL_BlitSurface(ButtonSurface,NULL,screen,&box); } What am I doing wrong here?

    Read the article

  • Can a ScatterViewItem dynamically resize to fit its content?

    - by Brett
    We're hosting a control inside of a ScatterViewItem that dynamically changes its size at runtime as a result of having various sub-elements added, removed, and/or collapsed. We would like to have the hosting ScatterViewItem resize as well to properly fit its child controls, but we're having a hard time making this happen. We've tried a number of different things and the closest we've come is hooking into the child control's SizeChanged event and explicitly setting the ScatterViewItem's Width and Height, but this approach still has issues. When you define a ScatterViewItem and its content in XAML, the ScatterViewItem is sized appropriately. We would like to force the same behavior at runtime when its content changes size. Any help would be greatly appreciated. Thanks!

    Read the article

  • Data-Virtualization problem with SurfaceScrollViewer

    - by TWith2Sugars
    I'm in a situation where I'm using an ItemsControl with a SurfaceScrollViewer bound to an AsyncVirtualizingCollection and all of the data is being requested. I'm aware that it's due to the ItemsControl request all of the data but I'm not sure how to get around this. I've tried the AsyncVirtualizingCollection bound to a ListBox and it works fine and I'm now attempting to having it bound to a SurfaceListBox but the problem persists. Any ideas of how to overcome this? Thanks & Regards Tony

    Read the article

  • how to animate 2 surfaces in Matlab?

    - by Kate
    Hi everyone, I've written this code which makes an animation of 2 ellipsoids. Parameter k1 of these ellipsoids must depend on time (so they'd move asynchronously), but I need to animate them in one figure. Can I use loop for it or is it better to use timer & some kind of callback functions? The second problem - I need to move inner ellipsoid so they would have one common side. How can I do this? a=5; b=a; c=10; u = (0:0.05*pi:2*pi)'; v = [0:0.05*pi:2*pi]; X = a*sin(u)*cos(v); Y = a*sin(u)*sin(v); Z = c*cos(u)*ones(size(v)); Z(Z0)=0; % cut upper V1=4/3*pi*a*b*c; d=1/2; e=2^d; a2=a/e; b2=a/e; c2=c; V2=4/3*pi*a2*b2*c2; X2 = a2*sin(u)*cos(v);%-2.5; Y2 = b2*sin(u)*sin(v); Z2 = c2*cos(u)*ones(size(v));%+0.25; Z2(Z20)=0; % cut h=1/3; for j = 1:20 k1=(sin(pi*j/20)+0.5)^h; a=a*k1; c=c*k1; X = a*sin(u)*cos(v); Y = a*sin(u)*sin(v); Z = c*cos(u)*ones(size(v)); Z(Z0)=0; a2=a2*k1; b2=a2*k1; c2=c2*k1; X2 = a2*sin(u)*cos(v)+5;%-2.5; Y2 = b2*sin(u)*sin(v); Z2 = c2*cos(u)*ones(size(v));%+0.25; Z2(Z20)=0; hS1=surf(X,Y,Z); alpha(.11) hold on hS2=surf(X2,Y2,Z2); hold off axis([-20 20 -20 20 -20 20]); F(j) = getframe; end movie(F,4)

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >