![]() |
You can also read this article in English at papagamedev.com. |
Después de que JPacman había dado las primeras señales de vida usando Cocos2d-x, era hora de hacer que por fin se pudiera volver a jugar. ¿Qué faltaba para esto? Dos cosas: que se vieran los gráficos en pantalla y que se pudiera usar el teclado para controlar menús y personaje.
Gráficos en Pantalla
Para poder mostrar los gráficos en pantalla y mantener la lógica que ya tenía implementada en la versión original de JPacman, tuve que revisar primero cómo era que funcionaba y en qué consistían los archivos de imágenes que el proyecto ya contenía.
Descubrí que JPacman cargaba sólo una gran imagen por escena. En la parte superior de cada imagen estaba el fondo de la escena, del tamaño de la pantalla completa a una resolución de 640 por 480 pixeles. Había cuatro escenas diferentes en el juego y por tanto había cuatro archivos de imagen: introducción, menú principal, pantalla de mejores puntajes y la escena del juego.

Cada una de los cuatro archivos tenía repetido en la parte inferior una serie de imágenes con todos los dibujos de las animaciones de los personajes y objetos dinámicos del juego. Me llamó mucho la atención que hace casi veinte años ya hubiera usado lo que se conoce en la industria como un atlas de texturas, pues es una de las maneras más eficientes de manejar archivos de imágenes en un videojuego de este tipo.

Tuve que convertir los archivos de imagen a PNG, pues la versión original de JPacman usaba archivos de imágenes en formato BMP, y Cocos2d-x no soporta ese formato. Además, separé el atlas de los fondos de las imágenes pues me pareció que sería mejor para manejar la carga y descarga de las imágenes.
Ya enfocado en el código, hacer funcionar los gráficos no fue difícil. Debí trabajar el archivo Gfx.cpp, en especial la función DrawSprite para poder registrar en el sistema de escena de Cocos2d-x a las imágenes que debían ser mostradas. También tuve que tener precaución con los sistemas de coordenadas pues descubrí, por las malas, que la coordenada Y estaba invertida entre Direct X y Cocos2d-x.
Por último, arreglé un fallo grosero que tenía en el código respecto a la variable GFXFile, con la que estaba haciendo lo que se conoce como «pisar memoria». Eso seguramente explica caídas inesperadas que había en la versión original y que nunca entendí por qué ocurrían. Para más detalles, pueden ver el código en Bitbucket y el cambio que hice.
Controles y Teclado
El siguiente paso era conseguir controlar los menús y personaje con el teclado. Inspeccionando el código, descubrí que también había programado (o copiado de alguna parte) la funcionalidad para poder utilizar controles con el juego, pero al parecer estaba incompleta. Desafío para más adelante, me dije.
Para que funcionara el teclado, primero tuve que modificar varios archivos porque las constantes que usaba para identificar las teclas entraban en conflicto con constantes de Cocos2d-x. A todas las constantes del juego les tuve que agregar el prefijo JPACMAN_, y con eso pude conseguir usarlas correctamente.
Luego, agregué el código para registrar un receptor de eventos (event listener) de Cocos2d-x y agregué el manejo de los eventos OnKeyPressed y OnKeyReleased, lo que resultó bastante más fácil de lo que yo esperaba.
¡JPacman ya se podía jugar nuevamente!

![]() |
You can also read this article in English at papagamedev.com. |
Hola! estaba mirando con mucha atención por el proceso que has pasado para re-vivir tu JPacman, me imagino que para esta altura ha sido una grata experiencia, sobretodo por la oportunidad que te ha dado de mirar un poco a nuevas herramientas que hay disponibles.
Bueno, no está demás decir que es muy interesante todo el proceso y opciones que se tienen hoy para crear juegos. En mi caso, siento que es un proceso de nunca acabar y las opciones son interminables.
Muy entretenido!
Saludos!
Perfect update of captchas solution software «XEvil 5.0»:
Captchas solving of Google (ReCaptcha-2 and ReCaptcha-3), Facebook, BitFinex, Microsoft, MailRu, SolveMedia, Hydra,
and more than 12000 another categories of captcha,
with highest precision (80..100%) and highest speed (100 img per second).
You can use XEvil 5.0 with any most popular SEO/SMM programms: iMacros, XRumer, SERP Parser, GSA SER, RankerX, ZennoPoster, Scrapebox, Senuke, FaucetCollector and more than 100 of other software.
Interested? There are a lot of demo videos about XEvil in YouTube.
FREE DEMO AVAILABLE!
Good luck 😉
P.S. A Huge Discount -30% for XEvil full version until 15 Jan is AVAILABLE! 🙂
XEvil.Net
Perfect update of captcha solving package «XEvil 5.0»:
Captchas solution of Google (ReCaptcha-2 and ReCaptcha-3), Facebook, BitFinex, Bing, MailRu, SolveMedia, Hydra,
and more than 12000 another categories of captcha,
with highest precision (80..100%) and highest speed (100 img per second).
You can use XEvil 5.0 with any most popular SEO/SMM software: iMacros, XRumer, SERP Parser, GSA SER, RankerX, ZennoPoster, Scrapebox, Senuke, FaucetCollector and more than 100 of other programms.
Interested? There are a lot of impessive videos about XEvil in YouTube.
Free XEvil Demo available.
Good luck!
P.S. A Huge Discount -30% for XEvil full version until 15 Jan is AVAILABLE! 🙂
XEvil.Net
cialis cheap cialis
Доставка алкоголя якутск
Доставка алкоголя якутск
Доставка алкоголя якутск
Заказать прогон сайта
Прогон хрумером
Качественный прогон Хрумером
Заказать прогон хрумером
Прогон сайта
прогон хрумер
canadianpharmacy buy online prescription drugs highest rated canadian pharmacies
cialis and viagra taken together viagra free sample viagra online
cialis usa cialis cialis without precription
aarp recommended canadian pharmacies cheap drugs viagra generic canadian pharmacy
arthritis viagra cheap cheapest cheap drugs online
motion sickness viagra super active pharmacy online cheap
Cialis Soft Tabs prescription drugs from canada online skin care
generic viagra buying inexpensive viagra best prices for generic viagra
cash loan fairfax va payday loan kaneohe castle payday loan agreement
how to get viagra without a doctor priligy viagra viagra cheap generic cialis
cialis cheapest price canada cialis gewГ¶hnung free sample of cialis canada
navy fcu cash advance money now loans rac payday loans
6 month cash advance loans payday loan website for sale cash advance alachua
llbean visa cash advance cash advance omaha nebraska payday loan store in gary indiana
viagra after age 70 generic name for viagra herbal viagra pills
buy cialis overnight shipping buy cialis online in usa cialis dapoxetine australia
ivermectin for squirrels buy ivermectin stromectol ivermectin/pyrantel and liver disease how much ivermectin do i give my goat
ventolin rotacaps albuterol tablets canada how long does albuterol last what does albuterol nebulizer do
chicken ivermectin how to buy stromectol is ivermectin and ivomec the same how much ivermectin horse paster dewormer for goat
albuterol high buy combivent inhaler what do inhalers such as ventolin do which works best for asthma proair albuterol or ventolin
furosemide pharmacokinetics furosemide 400 mg furosemide 40 mg tablet price what is nursing implication on pt on furosemide
amoxicillin adverse effects buy amoxicillin 500mg capsules uk does amoxicillin make you sleepy can i drink when taking amoxicillin
furosemide for furosemide 80 tablet spironolactone and furosemide in heart failure furosemide why drug of choice
zithromax no prescription generic zithromax 500mg india how long until zithromax works how to take azithromycin
azithromycin vs penicillin zithromax mexico what is zithromax used for in adults how much azithromycin
clomid otc clomid pills where to buy is it safe to order clomid online how long do side effects last for clomid
doxycycline for cats doxycycline pills can you drink on doxycycline how long does it take for doxycycline to work for tooth infection
prednisolone effects prednisolone 5 mg tablet without a prescription prednisolone acetate ophthalmic 1 suspension what is the shelf life of prednisolone 1%
doxycycline for urethritis doxycycline monohydrate how fast does doxycycline work why was my mother given doxycycline for her bronchitis
fertility pills clomid clomid costs australia buy clomid online no prescription when shouldwe havesex clomid
prednisone or prednisolone prednisolone 25mg tablets prednisone vs prednisolone vs methylprednisolone how to take your dog out of prednisolone 5mg
dapoxetine buy online genuine priligy for sale dapoxetine how often to take for depression where to buy dapoxetine using paypal
dapoxetine alcohol priligy cheapest uk can you be prescribed dapoxetine what is dapoxetine and sildenafil tablets
diflucan athlete’s foot diflucan can you have sex while taking diflucan what is the drug diflucan used for
propecia and women how do i get propecia do you need prescription for propecia how long can i miss taking propecia
prednisolone definition buy prednisolone tablets 5mg uk prednisolone, certirizine, valacyclovir how long does prednisolone take to work
It’ѕ rеally a cool and helpful piece of info.
I’m satissfied that you simply shared tһis
useful information with us. Please keеp us up to date
like this. Thanks free chatting for marrіage (freedatingsitesus.com) shаring.
It іѕ apρropriate time to make some plans for the
future and it’s time to be happy. I have read thіs рost and
if I mаy just I want to recommend you few fascinating things
or advice. Мaybe you can write subsequent articles relatіng to
this article. I want to learn evn mоre things approximatеly it!
Look into my blog ::free dating sites (http://freedatingsitesus.com/)
I was wⲟndеring if you evеr cоnsidered changing thе page lɑyout of your site?
Its νery well writtеn; I loge what yⲟyve ցot to say.
But maybe you coulⅾ a little more in the ԝay of
content so people coᥙjld connect with it betteг. Youѵe goot an awful lot of text forr only һаving one or 2 images.
Maybe you ϲould spaсe it ߋut Ьetter?
Heree iѕ my weƄ page payday loans amarillo tx
Hi tһere to all, foг the reason that I
am in fact eaɡer of reading tһiѕ blog’s post to be updatedd
on a гegular basіs. It includes fastidious stuff.
Here is my page payday loans dallas
neurontin overdose amount gabapentin cheapest price neurontin dosage for nerve pain how long does it take gabapentin to kick in
It is ρеrfect time to make some plans for the future
and it’s time to be happy. I have resad thiѕ post and if I could I desire to suggest yyou some intereѕting things or
advice. Maybe you couⅼd write next articles гeferring to this article.
I desire to read even mre thingѕ about іt!
Feel free too surf too mmy web sit – instant payday loans online
Wһat’s up, just wanted to mention, I likeԀ this blog post.
It was funny. Keep oon posting!
my website … payday loans denver
free adult personals
dating personal ads
Ꮋey I know this is off t᧐pic but I was wonderring if you knew of
anyy widgets I ϲould аdd to my blog that automatically tweet my newest twitter updates.
I’ve been looking for a ⲣlug-in lioe this for quitе
some time and wass hopіng maybe you would havе some experіence with something like
this. Please let me know if you run into
anything. I truly enjoy reading yoᥙr blog and I look forward to yojг new updates.
Here is my web-ѕite: payday loans md
janumet vs metformin metformin 850 mg cost side effects of metformin er 1000 mg how long does it take for metformin to leave your system
Thіs websijte was… how do yоu say it? Relevant!! Finally I’ve found something which helped me.
Thank you!
Here iis my website: checkmate payday loans
paxil withdrawals paroxetine 37.5mg price can paxil lower blood pressure how to stop taking paxil 10 mg
Excellent goods from уou, man. I’ve understand yoսr stuff
prevіious to and үou aree just too great. I reallү like what yyoᥙ have acquired here,
certainly liқe what you are stating and the way in whicһ
you ѕay it. Уοu make it entertaining and you stіll care for to keep
iit smart. I can not wait to read far more from you. This iѕ аctսally a terrіfiⅽ web free adult personals site.
plaquenil hair changes plaquenil coupon skipping a few doses of plaquenil what medicine should be taken with plaquenil
Pіece of writing writing is also a excitement, if you be acquаinted wіrh then yoou caan write if not it is compleх to write.
Feel free to visіt my wеb site; chat free dating site
Why people still make use of to read news ρaapers wheen in this technoⅼogіcal world the whole thing is aᴠaiⅼabⅼe on web?
Feеl free to suгf to mmy homepage: free foreign dating sites free no fee